What is the difference between Bufferreader and InputstreamReader in Java? tccicomputercoaching.com

Page 1

What is the difference between Bufferreader and InputstreamReader in Java? tccicomputercoaching.com BufferedReader and InputStreamReader are both Input Function in Java File. 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 specified stream and remaining characters still remain in the stream.

Example: 1. 2. 3.

class NewClass { public static void main(String args[]) throws InterruptedException, IOException 4. { 5. BufferedReader isr = new BufferedReader(new InputStreamReader(System.in)); 6. Scanner sc = new Scanner(System.in); 7. System.out.println("B.R. - "+(char)isr.read()); 8. System.out.println("Scanner - " + sc.nextLine()); 9. } 10. }


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.