Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4026570

I don't think the InputStreamReader class is working

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_95

      Description



      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 ###@###.###

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: