• JAVA生成二维码


    环境:

      1.eclipse

      2.jdk1.8

      3.tomcat8

      4.zxing3.2.1.jar

    具体实现:

      public static void main(String[] args) throws Exception {
            int width = 300;
            
            int height = 300;
            
            String format = "png";
            
            String content = "此处为二维码生成的内容";
            
            @SuppressWarnings("rawtypes")
            HashMap<EncodeHintType, Comparable> map = new HashMap<EncodeHintType, Comparable>();
            
            map.put(EncodeHintType.CHARACTER_SET,"UTF-8");
            map.put(EncodeHintType.ERROR_CORRECTION,ErrorCorrectionLevel.M);
            map.put(EncodeHintType.MARGIN,2);
            
            
            try {
                BitMatrix bitMatrix = new MultiFormatWriter().encode(content,BarcodeFormat.QR_CODE, width, height,map);
                Path file = new File("F:/code/img.png").toPath();
                MatrixToImageWriter.writeToPath(bitMatrix, format, file);
            } catch (WriterException e) {
                e.printStackTrace();
            }
        }

  • 相关阅读:
    Codeforces Round #239(Div. 2) 做后扯淡玩
    hdu 3507 Print Article
    prufer序列
    POJ 2778 DNA Sequence
    Codeforces Round #237 (Div. 2)
    poj3352
    图论知识
    POJ 2186
    Codeforces Round #236 (Div. 2)
    POJ 2823 Sliding Window
  • 原文地址:https://www.cnblogs.com/gslblog/p/6783178.html
Copyright © 2020-2023  润新知