高效字符流:能更快读写数据;
BufferedReader bir
= new BufferedReader(new FileReader("aaa.txt"));
BufferedWriter bfw
= new BufferedWriter(new FileWriter("dd88d.txt"));
String line
=null
;
while ((line
= bir
.readLine())!=null
){
bfw
.write(line
);
bfw
.newLine();
bfw
.flush();
}
bir
.close();
bfw
.close();
高效字节流:功能同上;
BufferedInputStream bis
= new BufferedInputStream(new FileInputStream("新上海滩 - 上海滩.mp3"));
BufferedOutputStream bos
= new BufferedOutputStream(new FileOutputStream("C:\\Users\\Administrator\\Desktop\\test"+"\\"+"新上海滩 - 上海滩copy3.mp3"));
int len
=0;
byte[] bytes
= new byte[1024 * 8];
long start
= System
.currentTimeMillis();
while ((len
=bis
.read(bytes
))!=-1){
bos
.write(bytes
,0,len
);
bos
.flush();
}
long end
= System
.currentTimeMillis();
System
.out
.println((end
-start
)+"毫秒");
bis
.close();
bos
.close();
转载请注明原文地址: https://mac.8miu.com/read-497169.html