What are the differences (if any) between the following two buffering approaches?
Reader r1 = new BufferedReader(new InputStreamReader(in, \"UTF-8\"), bufferSize
r1
is also more convenient when you read line-based stream as BufferedReader
supports readLine
method. You don't have to read content into a char array buffer or chars one by one. However, you have to cast r1
to BufferedReader
or use that type explicitly for the variable.
I often use this code snippet:
BufferedReader br = ...
String line;
while((line=br.readLine())!=null) {
//process line
}