zxing 3.0.1生成二维码,这么写怎么就是不对,MatrixToImageWriter类找不到,应该怎么写?
String contents = "今天,我们来简单聊聊google开源项目——ZXing(二维条码编解码)";
Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "GBK");
BitMatrix matrix = null;
try {
matrix = new MultiFormatWriter().encode(contents,
BarcodeFormat.QR_CODE, 300, 300, hints);
} catch (WriterException e) {
e.printStackTrace();
}
File file = new File("D://qrcodeImage.png");
try {
MatrixToImageWriter.writeToFile(matrix, "png", file);
} catch (IOException e) {
e.printStackTrace();
}
Class MatrixToImageWriter是在com.google.zxing.client.j2se包下面的,导入这个包试试