JDK-4026570 : I don't think the InputStreamReader class is working
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95
  • CPU: x86
  • Submitted: 1997-01-17
  • Updated: 1997-01-18
  • Resolved: 1997-01-18
Related Reports
Duplicate :  
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   ###@###.###

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

Comments
WORK AROUND Name: el35337 Date: 01/17/97 ======================================================================
11-06-2004