QRCodeUtil.java 728 Bytes
package com.pashanhoo.common;




import net.glxn.qrgen.core.image.ImageType;
import net.glxn.qrgen.javase.QRCode;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;

public class QRCodeUtil {


    public static void imgUrl(String url,String fileName)  {
        try{
            ByteArrayOutputStream out= QRCode.from(url).to(ImageType.PNG).stream();
            byte[] data = out.toByteArray();
            OutputStream oute = new FileOutputStream(new File("E:\\ewm\\"+fileName));
            oute.write(data);
            oute.flush();
            oute.close();
        }catch(Exception ex){
            ex.printStackTrace();
        }

    }


    

}