java 生产二维码报错 30
atcom.sf.ccwp.commonback.entity.orcode.CryptoUtils.main(CryptoUtils.java:336)overflow...
at com.sf.ccwp.commonback.entity.orcode.CryptoUtils.main(CryptoUtils.java:336)
overflow
java.lang.ArrayIndexOutOfBoundsException: 124
at com.swetake.util.Qrcode.divideDataBy8Bits(Qrcode.java:545)
at com.swetake.util.Qrcode.calQrcode(Qrcode.java:438)
at com.sf.ccwp.commonback.entity.orcode.TwoDimensionCodeUtil.qRCodeCommon(TwoDimensionCodeUtil.java:147)
at com.sf.ccwp.commonback.entity.orcode.TwoDimensionCodeUtil.encoderQRCode(TwoDimensionCodeUtil.java:104)
at com.sf.ccwp.commonback.entity.orcode.TwoDimensionCodeUtil.encoderQRCode(TwoDimensionCodeUtil.java:39)
at com.sf.ccwp.commonback.entity.orcode.CryptoUtils.main(CryptoUtils.java:339)
我把要生产二维码生产公钥加密 之后的信息 包这个错网上也找不到错误原因~
String imgPath = "D:/测试二维码图片.png";//生成图片路径。
String encoderContent = conter;//内容
int size =80;
TwoDimensionCodeUtil handler = new TwoDimensionCodeUtil();
handler.encoderQRCode(encoderContent, imgPath);
try {
OutputStream output = new FileOutputStream(imgPath);
handler.encoderQRCode(encoderContent, output);
} catch (Exception e) {
e.printStackTrace();
}
而且我发现 这个SIZE 属性怎么加了没有效果呢 展开
overflow
java.lang.ArrayIndexOutOfBoundsException: 124
at com.swetake.util.Qrcode.divideDataBy8Bits(Qrcode.java:545)
at com.swetake.util.Qrcode.calQrcode(Qrcode.java:438)
at com.sf.ccwp.commonback.entity.orcode.TwoDimensionCodeUtil.qRCodeCommon(TwoDimensionCodeUtil.java:147)
at com.sf.ccwp.commonback.entity.orcode.TwoDimensionCodeUtil.encoderQRCode(TwoDimensionCodeUtil.java:104)
at com.sf.ccwp.commonback.entity.orcode.TwoDimensionCodeUtil.encoderQRCode(TwoDimensionCodeUtil.java:39)
at com.sf.ccwp.commonback.entity.orcode.CryptoUtils.main(CryptoUtils.java:339)
我把要生产二维码生产公钥加密 之后的信息 包这个错网上也找不到错误原因~
String imgPath = "D:/测试二维码图片.png";//生成图片路径。
String encoderContent = conter;//内容
int size =80;
TwoDimensionCodeUtil handler = new TwoDimensionCodeUtil();
handler.encoderQRCode(encoderContent, imgPath);
try {
OutputStream output = new FileOutputStream(imgPath);
handler.encoderQRCode(encoderContent, output);
} catch (Exception e) {
e.printStackTrace();
}
而且我发现 这个SIZE 属性怎么加了没有效果呢 展开
3个回答
展开全部
你好,你可以参考我的这段代码,记得导入Zxing1.6.jar即可:
public static void main(String[] args) {
String myCodeText = "http://www.baidu.com";
String filePath = "d:/testqr/myQR.png";
int size = 125;
String fileType = "png";
File myFile = new File(filePath);
try {
Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix byteMatrix = qrCodeWriter.encode(myCodeText,BarcodeFormat.QR_CODE, size, size, hintMap);
int CrunchifyWidth = byteMatrix.getWidth();
BufferedImage image = new BufferedImage(CrunchifyWidth, CrunchifyWidth,
BufferedImage.TYPE_INT_RGB);
image.createGraphics();
Graphics2D graphics = (Graphics2D) image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, CrunchifyWidth, CrunchifyWidth);
graphics.setColor(Color.BLACK);
for (int i = 0; i < CrunchifyWidth; i++) {
for (int j = 0; j < CrunchifyWidth; j++) {
if (byteMatrix.get(i, j)) {
graphics.fillRect(i, j, 1, 1);
}
}
}
ImageIO.write(image, fileType, myFile);
} catch (WriterException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("\n\nYou have successfully created QR Code.");
}
记得采纳哦
public static void main(String[] args) {
String myCodeText = "http://www.baidu.com";
String filePath = "d:/testqr/myQR.png";
int size = 125;
String fileType = "png";
File myFile = new File(filePath);
try {
Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix byteMatrix = qrCodeWriter.encode(myCodeText,BarcodeFormat.QR_CODE, size, size, hintMap);
int CrunchifyWidth = byteMatrix.getWidth();
BufferedImage image = new BufferedImage(CrunchifyWidth, CrunchifyWidth,
BufferedImage.TYPE_INT_RGB);
image.createGraphics();
Graphics2D graphics = (Graphics2D) image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, CrunchifyWidth, CrunchifyWidth);
graphics.setColor(Color.BLACK);
for (int i = 0; i < CrunchifyWidth; i++) {
for (int j = 0; j < CrunchifyWidth; j++) {
if (byteMatrix.get(i, j)) {
graphics.fillRect(i, j, 1, 1);
}
}
}
ImageIO.write(image, fileType, myFile);
} catch (WriterException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("\n\nYou have successfully created QR Code.");
}
记得采纳哦
展开全部
ArrayIndexOutOfBoundsException
数组下标越界
数组下标越界
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你的grcode类在哪定义的你定义的grcode类中有setQrcoder....红色长方形里面的这些方法吗。
你如里是用jar包的话。你的jar包导入了吗。
希望能够帮助到你,望采纳!
你如里是用jar包的话。你的jar包导入了吗。
希望能够帮助到你,望采纳!
追问
没导包根本就没法运行吧。grcode跟这个方法有关系吗?这个报错信息貌似是因为我的内容过长的原因
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询