字符缓冲流
作者:互联网
package com.czie.iot1913.lps.IO.BufferStream;
import java.io.*;
/**
* FileName: BufferSteamDemo00
* Author: lps
* Date: 2022/3/26 15:34
* Sign:刘品水 Q:1944900433
* BufferedReader(Reader in)
* 创建一个使用默认大小输入缓冲区的缓冲字符输入流。
* BufferedReader(Reader in, int sz)
* 创建一个使用指定大小的输入缓冲区的缓冲字符输入流。
* BufferedWriter(Writer out)
* 创建一个使用默认大小输出缓冲区的缓冲字符输出流。
* BufferedWriter(Writer out, int sz)
* 创建一个新的缓冲字符输出流,该流使用给定大小的输出缓冲区。
*/
public class BufferSteamDemo00 {
public static void main(String[] args) throws IOException {
// FileWriter fw = new FileWriter("F:\\JavaCode\\bw.txt");
// BufferedWriter bw = new BufferedWriter(fw);
BufferedWriter bw = new BufferedWriter(new FileWriter("F:\\JavaCode\\bw.txt"));
// private static int defaultCharBufferSize = 8192;
//
// /**
// * Line separator string. This is the value of the line.separator
// * property at the moment that the stream was created.
// */
// private String lineSeparator;
//
// /**
// * Creates a buffered character-output stream that uses a default-sized
// * output buffer.
// *
// * @param out A Writer
// */
// public BufferedWriter(Writer out) {
// this(out, defaultCharBufferSize);
// }
bw.write("hello\r\nworld\r\njava");
bw.close();
BufferedReader br = new BufferedReader(new FileReader("F:\\JavaCode\\bw.txt"));
char[] chars = new char[1024];
int len;
while((len=br.read(chars))!=-1){
System.out.println(new String(chars,0,len));
}
}
}
标签:字符,int,缓冲,Writer,BufferedWriter,bw,new,out 来源: https://www.cnblogs.com/lps1944900433/p/16059081.html