Use a BufferedReader to read characters from the console. : Buffered Reader Writer « File Input Output « Java






Use a BufferedReader to read characters from the console.

  
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class BRRead {
  public static void main(String args[]) throws IOException {
    char c;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter characters, 'q' to quit.");
    do {
      c = (char) br.read();
      System.out.println(c);
    } while (c != 'q');
  }
}

   
  








Related examples in the same category

1.Read a string from console using a BufferedReader.
2.Creates a tiny text editor with BufferedReader
3.how to read lines from a file and print these to the standard output stream
4.Writing to a Text File
5.Fast BufferedWriter