public static void main(String[] args) throws Exception { // String imgPath = "D:\\Users\\Zhangjunqiao\\3_Files"; // try { // BufferedImage image = ImageIO.read(new FileInputStream(imgPath)); // } catch (FileNotFoundException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } String content = "http://www.sinaimg.cn/dy/slidenews/8_img/2015_36/65486_439634_724233.jpg"; BufferedImage image2 = QRCodeUtil.standEncodeQr(content); try { ImageIO.write(image2, "jpg", new File("D:\\Users\\Zhangjunqiao\\3_Files\\2.jpg")); } catch (IOException e) { e.printStackTrace(); } String imgUrl = "http://www.qq1234.org/uploads/allimg/140714/3_140714160149_5.png"; // 小黄人 try { BufferedImage image3 = QRCodeUtil.createImage(content, imgUrl); ImageIO.write(image3, "jpg", new File("D:\\Users\\Zhangjunqiao\\3_Files\\3.jpg")); } catch (Exception e) { e.printStackTrace(); } File file = new File("D:\\Users\\Zhangjunqiao\\3_Files\\2.jpg"); System.out.println("解析二维码的结果为:" + QRCodeUtil.decode(file)); }