为什么我的会报错误文件路径找不到?
java.io.FileNotFoundException: E:\ (系统找不到指定的路径。)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
at javax.imageio.stream.FileImageOutputStream.<init>(FileImageOutputStream.java:53)
at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(FileImageOutputStreamSpi.java:37)
at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:393)
at javax.imageio.ImageIO.write(ImageIO.java:1514)
at com.imooc.qrcode.CreateQRCode.main(CreateQRCode.java:66)
Exception in thread "main" java.lang.NullPointerException
at javax.imageio.ImageIO.write(ImageIO.java:1523)
at com.imooc.qrcode.CreateQRCode.main(CreateQRCode.java:66)
package com.imooc.qrcode;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.swetake.util.Qrcode;
public class CreateQRCode {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Qrcode x = new Qrcode();
x.setQrcodeErrorCorrect('M');//纠错等级
x.setQrcodeEncodeMode('B');//N代表数字,A代表a-Z,B代表其他字符
x.setQrcodeVersion(7); //版本
String qrData ="www.imooc.com";
int width = 300;
int height = 300;
//这是基于Java的JUI的画图工具来做的。
BufferedImage bufferedImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_BGR);
//画图工具,java的
Graphics2D gs = bufferedImage.createGraphics();
//背景颜色
gs.setBackground(Color.WHITE);
//图片颜色
gs.setColor(Color.BLACK);
//画板的内容
gs.clearRect(0, 0, width, height); //0,0指的是从画板的0开始
//偏移量,如果有时候不加偏移量,有时就导致我们解析错误。
int pixoff =2;
//这块是往我们的画板里面填充内容
byte[] d = qrData.getBytes("gb2312"); //如果有汉字的话,要转成gb2312
if(d.length > 0 && d.length < 120){
boolean[][] s = x.calQrcode(d);
for(int i=0; i<s.length; i++){
for(int j=0;j<s.length;j++){
if(s[j][i]){
gs.fillRect(j*3+pixoff, i*3+pixoff, 3, 3);
}
}
}
}
//结束我们的输出
gs.dispose();
bufferedImage.flush();
ImageIO.write(bufferedImage, "png", new File("E:/"));
}
}