public class InAndOutDemo {
public static void main(String[] args) {
FileInputStream fis=null;//输入流--读
FileOutputStream fos=null;//输出流--读
try {
fis=new FileInputStream("D:/我的青春谁做主.txt");
fos=new FileOutputStream("C:/myFile/my Prime.txt");
byte[] words=new byte[1024];
int len=-1;
//文件中的内容读取出来存放到了字节数组words中
while((len=fis.read(words))!=-1){
//将字节数组words写出到输出流fos中
fos.write(words,0,len);
}
System.out.println("文件复制完毕!");
}catch (FileNotFoundException e){
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
}finally {
try {
fos.close();
fis.close();
}catch (IOException e){
e.printStackTrace();
}
}
}
}