Java 字节流读写文件
import java.io.*;
class Test{
public static void main(String args[]){
FileInputStream fis = null;
FileOutputStream fos = null;
byte[] buffer = new byte[100];
int temp = 0;
try{
fis = new FileInputStream("D:/wenhao/src/from.txt");
fos = new FileOutputStream("D:/wenhao/src/to.txt");
while(true){
temp = fis.read(buffer,0,buffer.length);
if(temp == -1){
break;
}
fos.write(buffer,0,temp);
}
}
catch(Exception e){
System.out.println(e);
}
finally{
try{
fis.close();
fos.close();
}
catch(Exception e2){
System.out.println(e2);
}
}
}
}
欢迎访问:wenhao.ink