public static void main(String[] args) {int width = 300;int height = 300;String format = "png";String content = "www.imaac.com";//定义二维码的参数HashMap hints = new HashMap();hints.put(EncodeHintType.CHARACTER_SET,"UTF-8");hints.put(EncodeHintType.ERROR_CORRECTION,ErrorCorrectionLevel.M);hints.put(EncodeHintType.MARGIN, 2);try {BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height);Path file = new File("D:/img.png").toPath();MatrixToImageWriter.writeToPath(bitMatrix, format, file);} catch (Exception e) {e.printStackTrace();}}下斜杠Path和toPath()处有红线报错
添加回答
举报
0/150
提交
取消