BufferedReaderimproves performance by buffering input.
It hastwo constructors:
BufferedReader(Reader
InputStream)
BufferedReader(Reader
InputStream, intbufSize)
The
first form creates a buffered character stream using a default buffer size. In
the second, the size of the buffer is passed in bufSize.
Example:
import
java.io.*;
classBufferedreader
{
public
static void main(String args[]) throws IOException
{
FileReader
f=new FileReader("File1.txt");
BufferedReader
b=new BufferedReader(f);
String s;
while((s=b.readLine())!=null)
System.out.println(s);
}
}
Output:
Hello
this is written to the file using print stream
Again
the next line is also written to the file
No comments:
Write comments