6 月,1 周
Questions & Answers
175
- 无法逐行读取JSON类型的数据李>
- 无法使用以下命令将JSON对象中的值编码为图像
方法李>
public static void generate_qr(String name, String data) {
try {
String filePath = "W:\\FileDemo\\"+name+".png";
String charset = "UTF-8"; // or "ISO-8859-1"
Map < EncodeHintType, ErrorCorrectionLevel > hintMap = new HashMap < > ();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
BitMatrix matrix = new MultiFormatWriter().encode(
new String(/*qrObj.getString("projectkey")*/data.toString().getBytes(charset), charset),
BarcodeFormat.QR_CODE, 200, 200, hintMap);
MatrixToImageWriter.writeToFile(matrix, filePath.substring(filePath
.lastIndexOf(',') + 1), new File(filePath));
System.out.println("QR Code image created successfully!");
} catch (WriterException | IOException e) {
System.err.println(e);
}
}
共 (0) 个答案