Home Tutorial Java Core BufferReader Example

 
 

Share on Google+Share on Google+
BufferReader Example
Posted on: March 24, 2010 at 12:00 AM
Advertisement
In this tutorial you will see how BufferReader Class is used to read the character at the command line.

Code:

import java.io.*;

class BufferedRead {
public static void main(String args[])
throws IOException {
char c;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("\nEnter character 'x' to quit");

do {
c = (char) br.read();
} while (c != 'x');

}
}

How to run this example:

c:\yourJavaFileDir>javac BufferedRead.java

c:\yourJavaFileDir>java BufferedRead

Enter character 'x' to quit

Type the text and to quit type x and press enter to exit

The throw keyword example in java
This tutorial will demonstrate the use of the throw keyword. In this example you will see a sub-class is made of Exception. The throw keyword helps to call the subclass of Exception class that you made.
 
Advertisement

Related Tags for BufferReader Example:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 24, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com