package io1;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/*
* 实现文件的复制
* */
public class Copy {
public static void main(String[] args) {
File f = new File("E:/1.txt");
File f1 = new File("D:/1.txt");
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(f);
os = new FileOutputStream(f1);
byte[] b = new byte[1024];
int s = is.read(b);
while (s != -1) {
os.write(b);
s = is.read(b);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}