我读网络中的一张图片,想在保存到本地如下:: String path = "http://www.sun.com/im/a.gif";
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(path)));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File("d://aa")));
int i = 0;
byte[] b = new byte[1024];
while ((i = bis.read(b)) != -1) {
bos.write(b);
}
bis.close();
bos.close();为什么总是报异常如下::java.io.FileNotFoundException: http:\www.sun.com\im\a.gif (文件名、目录名或卷标语法不正确。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at cncomp.internet.operatorfile.Internet.savePic(Internet.java:93)
at cncomp.internet.operatorfile.ReadWeb.main(ReadWeb.java:26)
Exception in thread "main"
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(path)));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File("d://aa")));
int i = 0;
byte[] b = new byte[1024];
while ((i = bis.read(b)) != -1) {
bos.write(b);
}
bis.close();
bos.close();为什么总是报异常如下::java.io.FileNotFoundException: http:\www.sun.com\im\a.gif (文件名、目录名或卷标语法不正确。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at cncomp.internet.operatorfile.Internet.savePic(Internet.java:93)
at cncomp.internet.operatorfile.ReadWeb.main(ReadWeb.java:26)
Exception in thread "main"
InputStream is = url.openStream();