此前用来生成二维码的一篇文章中,我们首先要下载那个zxing-zxing-3.0的压缩包
然后将里面的core文件夹和javase文件夹下面的com文件,新建一个java项目,然后将com文件复制进去
然后export成jar包。然后,将jar包导入项目中的lib。
下面为zxing解析二维码。
public static void main(String[] args) throws Exception {
MultiFormatReader reader = new MultiFormatReader();
File file = new File("d://image.png");
BufferedImage image = ImageIO.read(file);
BinaryBitmap binaryBitMap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(image)));
HashMap hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
Result result = reader.decode(binaryBitMap, hints);
System.out.println(result.toString());
System.out.println(result.getTimestamp());
System.out.println(result.getText());
System.out.println(result.getBarcodeFormat());
}
来源:CSDN
作者:xulin5015
链接:https://blog.csdn.net/xulin5015/article/details/79508036