QRCode二维码生成

pom配置html

<dependency>
		    <groupId>com.github.cloudecho</groupId>
		    <artifactId>qrcode</artifactId>
		    <version>1.0.0</version>
		</dependency>

  代码java

public static void main(String []args)throws Exception{   
        String text = "http://www.bing.com/knows/search?q=%E8%B0%B7%E6%AD%8C%E5%9C%B0%E5%9B%BE&mkt=zh-cn&FORM=BKACAI";   
        int width = 300;   
        int height = 300;   
        String format = "png";   
        Hashtable hints= new Hashtable();   
        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");   
         BitMatrix bitMatrix = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE, width, height,hints);   
         File outputFile = new File("D:\\new.png");   
         MatrixToImageWriter.writeToFile(bitMatrix, format, outputFile);   
            
    }

  

 

转载于:https://www.cnblogs.com/tietazhan/p/6015892.htmlgit