Java BufferedReader ClassJava BufferedReader class is used to read the text from a character-based input stream. It can be used to read data line by line by readLine() method. It makes the performance fast. It inherits Reader class. Java BufferedReader class declarationLet's see the declaration for Java.io.BufferedReader class: Java BufferedReader class constructors
Java BufferedReader class methods
Java BufferedReader ExampleIn this example, we are reading the data from the text file testout.txt using Java BufferedReader class. Here, we are assuming that you have following data in "testout.txt" file: Welcome to javaTpoint. Output: Welcome to javaTpoint. Reading data from console by InputStreamReader and BufferedReaderIn this example, we are connecting the BufferedReader stream with the InputStreamReader stream for reading the line by line data from the keyboard. Output: Enter your name Nakul Jain Welcome Nakul Jain Another example of reading data from console until user writes stopIn this example, we are reading and printing the data until the user prints stop. Output: Enter data: Nakul data is: Nakul Enter data: 12 data is: 12 Enter data: stop data is: stop
Next TopicJava CharArrayReader Class
|