如何使用Java(J2SE)创建QRCode



如何使用普通j2se创建QRcode图像。有什么API或类可以做到这一点?

要做到这一点,您需要下载以下jar,

  • zxing-core-1.7罐
  • 中兴疫苗1.7.jar

来自http://code.google.com/p/zxing/

尝试以下代码

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
} 

希望这能帮助

最新更新