Java BufferedReader Class
BufferedReader Class in Java
The Java BufferedReader class reads text from a character input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. To perform console input use a byte stream. Today, using a byte stream to read console input is still acceptable.
For commercial applications, the preferred method of reading console input is to use a character oriented stream. This makes your program easier to internationalize and maintain. In Java, console input is accomplished by reading from System.in. To obtain a character based stream that is attached to the console, wrap System.in in a BufferedReader object. BufferedReader supports a buffered input stream.
System.in refers to an object of type InputStream, it can be used for inputStream.
In this tutorial you can learn about java io BufferedReader class. And how to use java io BufferedReader class examples.
What is Java BufferedReader Class ?
The Java BufferedReader class is used to read the stream of characters from the specified source.
The following program shows how to get input from console using java.
How to read the characters from the console
The above program output may look a little different from what you expected because System.in is line buffered, by default. This means that no input is actually passed to the program until you press ENTER. As you can guess, this does not make read() particularly valuable for interactive console input.
The following program demonstrates BufferedReader and the readLine() method; the program reads and displays lines of text until you enter the word "stop".
How to read the lines of text from the console
How to print only directory names using java? How to get only directories from given path using java?
How to read the text from file using Java BufferedReader
How to print available file system root names using java? How to get file system roots using java? How to get available drives using java?
How to read total bytes from file into array using Java BufferedReader
How to read text line by line from file using Java BufferedReader
How to read bytes from file using Java BufferedReader
How to read bytes from file using java BufferedReader