java文件拷贝
import java.io.*;
public class jcopy {
public static void main(String args[]){
try {
jcopy j = new jcopy();
j.CopyFile(new File("e:/file1.txt"),new File("e:/a.txt"));
}
catch (Exception e) {
e.printStackTrace();
}
}
public void CopyFile(File in, File out) throws Exception {
FileInputStream fis = new FileInputStream(in);
FileOutputStream fos = new FileOutputStream(out);
byte[] buf = new byte[1024];
int i = 0;
while((i=fis.read(buf))!=-1) {
fos.write(buf, 0, i);
}
fis.close();
fos.close();
}
}