输入流
FileOutputStream fos = new FileOutputStream("IO\\a.txt");
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write("想你想到疯了".getBytes());
bos.flush();刷新,以便写入
bos.close();释放内存
.
.
输出流
文件复制
long s = System.currentTimeMillis();
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("IO\\海尔恰饭.mp3"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("IO\\难听.mp3"));
/*FileInputStream*/
byte[] bytes = new byte[1024];
int len = 0;
while((len = bis.read(bytes)) != -1){
bos.write(len);
}
long e = System.currentTimeMillis();
System.out.println(e-s);
bos.close();
bis.close();