zoukankan      html  css  js  c++  java
  • 二维码生成

    项目中用到的,以免以后会再次遇到。

    一。需要两个jar包

      zxing-javase.jar

      zxing.jar

    二。配置需要生成二维码的参数

    三。生成二维码方法,方法返回值可改变

    //生成二维码
    	public String generateQRCode(String orderId,String qrCode){
    		try {
    		//物理路径
    		String path = ApplicationContext.getProperty("RechargeCode");
    		File file = new File(path);
    		String filePath = file.getName() + File.separator + orderId + ".png";
    		path += orderId + ".png";
    		int width = 900;   
    		        int height = 900;   
    		        String format = "png";
    		        Hashtable hints= new Hashtable();   
    		        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");   
    		        BitMatrix bitMatrix = new MultiFormatWriter().encode(qrCode, BarcodeFormat.QR_CODE, width, height,hints);   
    		        File outputFile = new File(path);   
    		        MatrixToImageWriter.writeToFile(bitMatrix, format, outputFile);
    		        return filePath;
    		} catch (Exception e) {
    		e.printStackTrace();
    		}
    		return null;
    		}
    

      

  • 相关阅读:
    mysql_day04
    四则运算_EX
    第二阶段站立会议9
    对搜狗输入法的评价
    找水王
    第二阶段站立会议8
    第二阶段站立会议7
    第二次站立冲刺会议6
    第二阶段站立冲刺会议5
    第二阶段站立冲刺会议4
  • 原文地址:https://www.cnblogs.com/wuao/p/7073924.html
Copyright © 2011-2022 走看看