java创建二维码

来源:互联网 发布:怪物猎人3数据库 编辑:程序博客网 时间:2024/06/05 19:34

java创建二维码的方式有很多,这里所用的我个人认为是比较简单的。
一下是我的代码结构:
这里写图片描述
代码实现:

/** * Title: java实现二维码打印,图片格式 * Description: TestDemo * @author lu * @date 2016年6月23日 下午2:48:53 */public class QRCodeUtil {        try {            //二维码内容以及生成地址             String content = "http://mp.weixin.qq.com";             String path = "d:/my180.jpg";             File foFile=new File(path);             //生成二维码            ByteArrayOutputStream out = QRCode.from(content).to(ImageType.JPG).withSize(250, 250).stream();            //图片写出路径            FileOutputStream fout = new FileOutputStream(foFile);            fout.write(out.toByteArray());            fout.flush();            fout.close();            System.out.println("生成结束!");         } catch (Exception e) {             e.printStackTrace();         }}
0 0
原创粉丝点击