Java tutorial: how to use Bufferedreader class

In this tutorial I will explain to you how you can use the Bufferedreader class in Java. Bufferedreader is a Java class that reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.

You can use Bufferedreader to get input information:

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

and display the information:

String s = reader.readLine();
System.out.println(s);

There is a full example:

import java.io.*;

public class Main {
public static void main(String[] args) throws IOException
{

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a number: ");
String s = reader.readLine();
System.out.println("Your number is: "+s);
}

}

I have created also a video tutorial where you can see how it works.









Leave a Comment