标签:pre fileinput out 输入流 简单 数组 red java dwr
BufferedInputStream 是缓冲输入流。它继承于FilterInputStream。BufferedOutputStream 是缓冲输出流。它继承于FilterOutputStream。
BufferedOutputStream 的作用是为另一个输出流提供“缓冲功能”。
使用FileInput和FileOutputStream操作文件流http://blog.51cto.com/13758648/2301470
-----
//Buffered的read是带缓存的,可以减少硬盘读写的次数
FileOutputStream fos = new FileOutputStream("test.txt");
BufferedOutputStream buffer = new BufferedOutputStream(fos);
buffer.write("sdfggsgsgsg".getBytes());
buffer.close();
-----
FileInputStream fis = new FileInputStream("test.txt");
BufferedInputStream bis = new BufferedInputStream(fis);
byte[] buf = new byte[100];
int len = bis.read(buf);
System.out.println(new String (buf,0,len));
fis.close();
FileOutputStream fos = new FileOutputStream("test.txt");
OutputStreamWriter osw = new OutputStreamWriter(fos);
BufferedWriter bw = new BufferedWriter(osw);
osw.write("程沐喆");
// bw.write("chengmuzhe");
bw.close();
osw.close();
//
-----
//
FileInputStream fis = new FileInputStream("test.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader bf = new BufferedReader(isr);
System.out.println(isr.read());
System.out.println(bf.readLine());
bf.close();
isr.close();
-----
JavaI/O:简单的使用BufferedOutputStream和BufferedInputStr
标签:pre fileinput out 输入流 简单 数组 red java dwr
原文地址:http://blog.51cto.com/13758648/2301472