Reply to comment

Corrected BufferedReader example

Here's a corrected version of your code:

import java.io.*;

public class BRRead
{
  public static void main( String args []) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter character, 'q' to quit");

    char c;
    while ( (c = (char)br.read()) != 'q')
    {
      System.out.println("char: " + c + ".");
    }
  }
}

You were very close, except for a few typos.

Also, sorry, I don't use NetBeans, and I don't know how to make this work from there. I just run it from the command line (Unix command line, in my case).

I hope that is helpful, and thanks for the nice "while loop" example of this code.

 

Reply

The content of this field is kept private and will not be shown publicly.