程序運行正常 但是就是不能生成二維碼
package com.zxing;
import java.io.File;
import java.nio.file.Path;
import java.util.HashMap;
import com.google.zxing.*;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
public class CreatQRcode {
public static void main(String[] args) {
// TODO 自動生成的方法存根
int width=300;
int height=300;
String format = "png";
String contents = "www.immoc.com";
//定義二維碼的參數(shù)
HashMap hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.ERROR_CORRECTION,ErrorCorrectionLevel.M);
hints.put(EncodeHintType.MARGIN, 2);
//生成二維碼
try {
BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, width, height,hints);
Path file ?= new File("D:/eclipse/immoc.png").toPath();
MatrixToImageWriter.writeToPath(bitMatrix, format, file);
} catch (Exception e) {
// TODO 自動生成的 catch 塊
e.printStackTrace();
}
}
}
2017-10-24
報錯原因截圖發(fā)下
2017-10-02
是不是地址的問題
2017-09-07
我的咋可以,我新手啊
2017-09-07
顯示我的程序有異常斷點兩項 但是位置未知。。。
2017-09-07
用的jar包是老師給的 ?jdk是1.8的