标签:系统 pypi des load puts file ace ase png
读出文件的路径需要有被拷贝的文件名,否则无法解析地址
package com.javase.IO.Stream;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyPicture {
@Test
public void copy(){
File srcFile = new File("D:\\test.jpg");
File destFile = new File("F:\\");
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(srcFile);
fos = new FileOutputStream(destFile);
byte[] bytes = new byte[1024 * 1024];
int len = 0;
while((len = fis.read(bytes)) != -1){
fos.write(bytes,0,len);
}
fos.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (fos != null) {
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
package com.javase.IO.Stream;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyPicture {
@Test
public void copy(){
File srcFile = new File("D:\\test.jpg");
File destFile = new File("F:\\test.jpg");
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(srcFile);
fos = new FileOutputStream(destFile);
byte[] bytes = new byte[1024 * 1024];
int len = 0;
while((len = fis.read(bytes)) != -1){
fos.write(bytes,0,len);
}
fos.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (fos != null) {
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
完美解决JavaIO流报错 java.io.FileNotFoundException: F:\ (系统找不到指定的路径。)
标签:系统 pypi des load puts file ace ase png
原文地址:https://www.cnblogs.com/Neroblogs/p/14524320.html