google zxing 依赖包
<dependency> <groupId>com.google.zxing</groupId> <artifactId>javase</artifactId> <version>3.2.1</version> </dependency>

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
String text = "hello world 2015.12.30";
String path = "E:\\hello-world.jpg";
Map< EncodeHintType, String > hints = new HashMap< EncodeHintType, String >();
hints.put( EncodeHintType.CHARACTER_SET, "UTF-8" );
BitMatrix bitMatrix = new MultiFormatWriter().encode( text, BarcodeFormat.QR_CODE, 400, 400, hints );
MatrixToImageWriter.writeToPath( bitMatrix, "jpg", Paths.get( path ) );
本文介绍了一个使用googlezxing库生成QR码的具体示例。通过设置文本内容、保存路径及字符集等参数,实现了QR码的创建与保存。

4000

被折叠的 条评论
为什么被折叠?



