import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileCopy {
public static void main(String[] args) {
//文件拷贝 要求将E盘上的pic1.jpg文件拷贝到E盘的Copy.jpg
FileCopy c=new FileCopy();
c.Copy();
}
public void Copy() {
//读取原文件
int read = 0;
String pathname = "e:\pic1.jpg";
String destname="e:\Copy.jpg";
FileInputStream fis = null;
FileOutputStream fos=null;
byte b[]=new byte[1024];
try {
fis = new FileInputStream(pathname);
fos=new FileOutputStream(destname);
while ((read = fis.read(b)) != -1) {
fos.write(b,0,read);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fis.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
文件的拷贝



