简体   繁体   中英

How to Create QRCode using Java (J2SE)

How to create QRcode image using normal j2se. Any APIs or classes are available to do this?

To do this you need to download following jars,

  • zxing-core-1.7.jar
  • zxing-javase-1.7.jar

from http://code.google.com/p/zxing/

try the following code

ByteArrayOutputStream out = QRCode.from("Hello World").to(ImageType.PNG).stream();

try {
    FileOutputStream fout = new FileOutputStream(new File("C:\\QR_Code.JPG"));

    fout.write(out.toByteArray());

    fout.flush();
    fout.close();

} catch (FileNotFoundException e) {
    // Do Logging
} catch (IOException e) {
    // Do Logging
} 

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM