亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

找不到實體類啊

我表示找不到這個類 MatrixToImageWritoter ? ?我的jar包里沒有?還是要單獨導入一個實體類?網上的實體類又沒有topath的方法...... 求助

正在回答

2 回答

還需要導入那個jar包?。??

0 回復 有任何疑惑可以回復我~
#1

慕粉3333056

com.google.zxing.client.j2se這個包
2017-03-25 回復 有任何疑惑可以回復我~

你是jar包沒有導入成功吧 我按著老師做的 沒有問題


這個是我寫的 你可以看看是不是這樣

package?com.imooc.zxing;

import?com.google.zxing.*;
import?com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import?com.google.zxing.client.j2se.MatrixToImageWriter;
import?com.google.zxing.common.BitMatrix;
import?com.google.zxing.common.HybridBinarizer;
import?com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

import?javax.imageio.ImageIO;
import?java.awt.image.BufferedImage;
import?java.io.File;
import?java.nio.file.Path;
import?java.util.HashMap;

/**
?*?生成二維碼
?*/
public?class?CreateQRCode?{
????public?static?void?main(String[]?args)?{
????????createQRCode();
//????????readQRCode();
????}

????private?static?void?readQRCode()?{
????????try?{
????????????MultiFormatReader?formatReader?=?new?MultiFormatReader();
????????????File?file?=?new?File("e:/image.png");
????????????BufferedImage?image?=?null;
????????????image?=?ImageIO.read(file);
????????????HashMap?hashMap?=?new?HashMap();
????????????hashMap.put(EncodeHintType.CHARACTER_SET,?"utf-8");
????????????BinaryBitmap?binaryBitmap?=?new?BinaryBitmap(new?HybridBinarizer(new?BufferedImageLuminanceSource(image)));
????????????Result?result?=?formatReader.decode(binaryBitmap,?hashMap);
????????????System.out.println("解析結果:"+result.toString());
????????????System.out.println("二維碼格式類型:"+result.getBarcodeFormat());
????????????System.out.println("二維碼文本:"+result.getText());

????????}?catch?(Exception?e)?{
????????????e.printStackTrace();
????????}
????}

????private?static?void?createQRCode()?{
????????int?width?=?300;
????????int?height?=?300;
????????String?format?=?"png";
????????String?content?=?"www.baidu.com";

????????//定義二維碼的參數
????????HashMap?hashMap?=?new?HashMap();
????????hashMap.put(EncodeHintType.CHARACTER_SET,?"utf-8");
????????hashMap.put(EncodeHintType.ERROR_CORRECTION,?ErrorCorrectionLevel.M);
????????hashMap.put(EncodeHintType.MARGIN,?5);

????????try?{
????????????BitMatrix?bitMatrix?=?new?MultiFormatWriter().encode(content,?BarcodeFormat.QR_CODE,?width,?height);
????????????Path?file?=?new?File("e:/img.png").toPath();
????????????MatrixToImageWriter.writeToPath(bitMatrix,?format,?file);
????????}?catch?(Exception?e)?{
????????????e.printStackTrace();
????????}
????}
}


0 回復 有任何疑惑可以回復我~
#1

angle_xin 提問者

謝謝拉 我發現依賴個包 我又導入了一個jar包 就有這個類了
2016-08-24 回復 有任何疑惑可以回復我~
#2

慕前端8116659 回復 angle_xin 提問者

也遇到同樣的問題了
2017-09-17 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Java生成二維碼
  • 參與學習       84574    人
  • 解答問題       279    個

二維碼無處不在,自己動手用Java生成二維碼,三種生成方式任你選

進入課程

找不到實體類啊

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號