利用zxing中jse开发包。
public static void main(String[] args) throws WriterException {
String text = "hello, world !";
Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
// hints.put(EncodeHintType.MARGIN, "5");
BitMatrix matrix = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE, 200, 200, hints);
File file = new File("qrcodeImage.png");
try {
MatrixToImageWriter.writeToFile(matrix, "png", file);
// MatrixToImageWriter.toBufferedImage(matrix);
} catch (IOException e) {
e.printStackTrace();
}
}
来源:oschina
链接:https://my.oschina.net/u/72663/blog/124265