생성자의 버퍼 크기 감각은 무엇입니까? 내가 프로그램을 쓴 것처럼BufferedReader의 버퍼 크기는 얼마입니까?
BufferedReader(Reader in, int size)
:
import java.io.*;
class bufferedReaderEx{
public static void main(String args[]){
InputStreamReader isr = null;
BufferedReader br = null;
try{
isr = new InputStreamReader(System.in);
// System.out.println("Write data: ");
// int i = isr.read();
// System.out.println("Data read is: " + i);
//Thus the InputStreamReader is useful for reading the character from the stream
System.out.println("Enter the data to be read by the bufferedReader: ");
//here isr is containing the lnefeed already so this is needed to be flushed.
br = new BufferedReader(isr, 2);
String str = br.readLine();
System.out.println("The data is : :" + str);
}catch(IOException e){
System.out.println("Can't read: " + e.getMessage());
}
}
}
출력 :
Enter the data to be read by the bufferedReader: Hello world and hello world again
The data is: Hello world and hello world again
그리고 내가 그것을 두 개의 문자를 읽어 것이라고 의도 한대로 버퍼 크기가 의미하는 일. 그러나 그것은 그렇지 않았습니다.
그러면 버퍼 크기의 의미는 무엇입니까? 설명해 주시겠습니까? – codeomnitrix
@codeonnitrix 약간의 설명이 추가되었습니다. 그게 충분한 지 알려주세요. – marcog
감사합니다 marcog .. – codeomnitrix