From 5b65962537abd3e50501dc7034d38439dd857d81 Mon Sep 17 00:00:00 2001 From: yem_rabbit_lhb Date: Wed, 8 Jan 2025 15:46:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20yem-base/yem-base-common/s?= =?UTF-8?q?rc/main/java/yem/base/common/utils/QRCodeToolUtil.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yem/base/common/utils/QRCodeToolUtil.java | 52 ------------------- 1 file changed, 52 deletions(-) delete mode 100644 yem-base/yem-base-common/src/main/java/yem/base/common/utils/QRCodeToolUtil.java diff --git a/yem-base/yem-base-common/src/main/java/yem/base/common/utils/QRCodeToolUtil.java b/yem-base/yem-base-common/src/main/java/yem/base/common/utils/QRCodeToolUtil.java deleted file mode 100644 index 59065e4..0000000 --- a/yem-base/yem-base-common/src/main/java/yem/base/common/utils/QRCodeToolUtil.java +++ /dev/null @@ -1,52 +0,0 @@ -package yem.base.common.utils; - - - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.EncodeHintType; -import com.google.zxing.WriterException; -import com.google.zxing.client.j2se.MatrixToImageWriter; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.qrcode.QRCodeWriter; -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; - - -/** - * @BelongsProject: yem-cosmic - * @BelongsPackage: yem.base.common.utils - * @ClassName QRCodeToolUtil - * @Author: LiuHB - * @CreateTime: 2025-01-08 15:32 - */ -public class QRCodeToolUtil { - - public static void main(String[] args) { - - String qrCodeText = "这里为二维码要展示内容文本"; - String filePath = "D:/1fileTest/qrcode1111.png"; - String fileType = "png";//文件类型 - int size = 250;//长宽 - createQRImage(qrCodeText, filePath, fileType, size); - - } - - private static void createQRImage(String qrCodeText, String filePath, String fileType, int size) { - File qrFile = new File(filePath); - try { - Map hintMap = new HashMap<>(); - hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); - hintMap.put(EncodeHintType.CHARACTER_SET, "utf-8"); - QRCodeWriter qrCodeWriter = new QRCodeWriter(); - BitMatrix bitMatrix = qrCodeWriter.encode(qrCodeText, BarcodeFormat.QR_CODE, size, size, hintMap); - MatrixToImageWriter.writeToPath(bitMatrix, fileType, qrFile.toPath()); - } catch (WriterException | IOException e) { - e.printStackTrace(); - } - } - -} \ No newline at end of file