QRCodeUtils是一个基于ZXing的二维码工具类,功能包括二维码生成和解析。
Method | Param | Detail |
---|---|---|
QRUtils encode(String content) |
|
|
QRUtils encode(String content, String outputPath) |
|
|
QRUtils encode(String content, String outputPath, String logoPath)) |
|
|
QRUtils encode(String content, String outputPath, String logoPath, int qrcodeSize) |
|
|
QRUtils encode(String content, String outputPath, String logoPath, int qrcodeSize, String qrcodeColor) |
|
|
QRUtils writeToFile(String outputPath) |
|
|
String decode(String inputPath) |
|
|
BufferedImage getQRCodeImage() |
|
- Encode
import com.zengyu.QRUtils;
public class Test {
public static void main(String[] args) {
QRUtils utils = new QRUtils();
utils.encode("https://github.com/frogfans/QRCodeUtils", "/home/zengyu/eclipse-workspace/", "/home/zengyu/eclipse-workspace/logo.jpeg", 0, "#0000ff");
}
}
控制台输出:
Output: /home/zengyu/eclipse-workspace/1522634604303.jpg
Encoding successful.
二维码图片:
- Decode
import com.zengyu.QRUtils;
public class Test {
public static void main(String[] args) {
QRUtils utils = new QRUtils();
utils.decode("/home/zengyu/git/QRCodeUtils/image/1522634604303.jpg");
}
}
控制台输出:
Output: https://github.com/frogfans/QRCodeUtils
Decoding successful.
- 3.3.2
jar文件名的版本号同ZXing的版本号。