字节流、字符流、缓冲流
字节流:
FileInputStream明确数据源,FileOutputStream明确目的地
FileInputStream fis=new FileInputStream("D:\\aaa\\aaa.rar");
FileOutputStream foss=new FileOutputStream("D:\\bbb\\aaa\\aaa.txt");
int len=0;
//单个字节
while((len=fis.read())!=-1){
fos.write(len);
}
//字节数组
byte[] bytes=new byte[1024];
while((len=fis.read(bytes))!=-1){
fos.write(bytes,0,len);
}
字符流:
FileReader
FileWriter
//字节+缓冲流:
BufferedInputStream,BufferedOutputStream
new BufferedInputStream(fos)
new BufferedOutputStream(fis)