java 使用qrcode生成二維碼需求調研的記錄

<!--生成二維碼-->
<dependency>
    <groupId>com.google.zxing</groupId>
    <artifactId>core</artifactId>
    <version>3.3.0</version>
</dependency>
<dependency>
    <groupId>com.google.zxing</groupId>
    <artifactId>javase</artifactId>
    <version>3.3.0</version>
</dependency>
這裏是我查需求的時候查到的資料並不完善,請忽略寫法和其他東西重點放在功能點上,
這個還是有很多侷限性的東西,比如說二維碼中的內容不能超過125字節,使用微信掃出來的內容只能是字符串 和 微信的名片(寫法百度上有很多)
並不適用於我現在的需求只是在這裏做個記錄
@SneakyThrows
public static void test() {
   QRCodeWriter qrCodeWriter = new QRCodeWriter();
   String codePath = "C:\\Users\\hw\\Desktop"+"\\"+"code"+".png";
   BitMatrix bitMatrix = qrCodeWriter.encode("123", BarcodeFormat.QR_CODE, 300, 300);
   Path path = FileSystems.getDefault().getPath(codePath);
   MatrixToImageWriter.writeToPath(bitMatrix,"PNG", path);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章