public static void code() {
try {
// File content = new File("C:/Users/s1331/Desktop/微信图片_20221008144808.jpg");
String content = "https://smwl-search-car.bj.bcebos.com/file2022-10-08/edfd8bce-392b-4d26-834a-284db865e8da.jpg"; //https://smwl-search-car.bj.bcebos.com/file2022-10-08/a7912daa-8fbb-471c-b9e5-5b4039f189d3.jpg
String path = "C:/Users/s1331/Desktop";// 二维码保存的路径C:/Users/s1331/Desktop
String codeName ="测试数据";// 二维码的图片名
String imageType = "jpg";// 图片类型
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
Map<EncodeHintType, String> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400, hints);
File file1 = new File(path, codeName + "." + imageType);
MatrixToImageWriter.writeToFile(bitMatrix, imageType, file1);
} catch (Exception e) {
e.printStackTrace();
}
}
08-04
1048
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交