package com.sxt;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* 缓存字节流(处理流 包装流)
*
* @author Administrator
*
*/
public class BufferedInputDemo {
public static void main(String[] args) throws IOException {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("c:/abc.txt"));
byte[] b = new byte[1024];
StringBuffer sb = new StringBuffer();
while (bis.read(b) != -1) {
sb.append(new String(b));
}
System.out.println(sb);
bis.close();
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("c:/aaa.txt"));
bos.write("我是李四,我不怕张三".getBytes());
bos.close();
}
}
网友评论