import java.io.*;
class Test
{
public static void main(String args[]){
FileInputStream fin =null;
FileOutputStream fout = null;
try{
fin = new FileInputStream("e://d/from.txt");
fout = new FileOutputStream("e://d/to.txt");
byte [] arr =new byte[1024];while(true){
int temp = fin.read(arr,0,arr.length);
if(temp == -1){ //读取到末端返回-1
break;
}
fout.write(arr,0,temp);
}}catch(Exception e){
System.out.println(e);
}
finally{ //关掉流
try{
fin.close();
fout.close();
}catch(Exception e){
System.out.println(e);
}}
}
}
java:IO-读写大文件
时间: 2024-11-04 20:46:47