处理流:增强功能、提供性能,节点流之上
1)、字节缓冲流
BufferedInputStream
BufferedOutputStream
public class TestBufferedByte {
public static void main(String[] args) throws IOException{
File src = new File("E:/workspace/images/bg.jpg");
File dest = new File("E:/workspace/images/bg11.jpg");
InputStream is = new BufferedInputStream(new FileInputStream(src));
OutputStream os = new BufferedOutputStream(new FileOutputStream(dest));
byte[] car = new byte[1024];
int len =0;
while(-1 != (len = is.read(car))){
os.write(car);
}
os.flush();
os.close();
is.close();
}
}
2)、字符缓冲流
BufferedReader readline()
BufferedWriter newLine()
public class TestBufferedChar {
public static void main(String[] args) throws IOException {
File src = new File("E:/workspace/images/a.txt");
File dest = new File("E:/workspace/images/b.txt");
BufferedReader br = new BufferedReader(new FileReader(src));
BufferedWriter bw = new BufferedWriter(new FileWriter(dest));
String str = null;
while(null != (str = br.readLine())){
bw.write(str);
bw.newLine();
}
bw.flush();
bw.close();
br.close();
}
}