I don't think the InputStreamReader class is working

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P2
    • None
    • Affects Version/s: 1.1
    • Component/s: core-libs
    • None
    • x86
    • windows_95



      Name: el35337 Date: 01/17/97

      I try to run this code :
      import java.io.*;

      class simple
      {^D
       public static void main(String[] args)
        {
         String userInput;
         // Exactly the same line from your documentation on the
         // InputStreamReader class e.g. the example line.
         BufferedReader in = new BufferedReader(new
                                 InputStreamReader(System.in));
         try
          {
           userInput = in.readLine();
          }
         catch (IOException e)
          {
           System.out.println("Can't read from stdin: " + e);
           System.exit(1);
          }

         try
          {
           if (in != null)
            in.close();
          }
         catch (IOException e)
          {
           System.out.println("Can't close stdin stream");
           System.exit(1);
          }
        }
      }^D

      When I try to run this I immediately get
      "Can't read from stdin: java.io.IOException"
      It doesn't even wait for me to type in the text. I do not know whether
      the stream thinks it is always going to be null or it expects input
      immediately after it is run. I tried using the FileReader class instead
      of the InputStreamReader class and it works fine. I also, however, tried
      to use the read() method as well e.g. to read just one character in.
      This gave exactly the same exception error.

      University of Southhampton ###@###.###

      ======================================================================

            Assignee:
            Mark Reinhold
            Reporter:
            Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: