Concept of Reader class and Input Stream class


Getting string using buffered Reader class and Input Stream class

BufferedReader reads a couple of characters from the specified stream and stores it in a buffer. This makes input faster.

InputStreamReader reads only one character from the specified stream and remaining characters still remain in the stream.

For example:-

import java.io.InputStreamReader;

import java.io.BufferedReader;

public class InputBR

{

    public static void main(String []args)throws Exception

   {

         InputStreamReader isr= new InputStreamReader(System.in);

         BufferedReader br= new BufferedReader(isr);

         String str= br.readLine();

         System.out.println(“Entered String is : “+str);

    }

}

Leave a comment