src/share/classes/java/io/InputStreamReader.java

Print this page
rev 10048 : 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
Reviewed-by:


  39  *
  40  * <p> Each invocation of one of an InputStreamReader's read() methods may
  41  * cause one or more bytes to be read from the underlying byte-input stream.
  42  * To enable the efficient conversion of bytes to characters, more bytes may
  43  * be read ahead from the underlying stream than are necessary to satisfy the
  44  * current read operation.
  45  *
  46  * <p> For top efficiency, consider wrapping an InputStreamReader within a
  47  * BufferedReader.  For example:
  48  *
  49  * <pre>
  50  * BufferedReader in
  51  *   = new BufferedReader(new InputStreamReader(System.in));
  52  * </pre>
  53  *
  54  * @see BufferedReader
  55  * @see InputStream
  56  * @see java.nio.charset.Charset
  57  *
  58  * @author      Mark Reinhold
  59  * @since       JDK1.1
  60  */
  61 
  62 public class InputStreamReader extends Reader {
  63 
  64     private final StreamDecoder sd;
  65 
  66     /**
  67      * Creates an InputStreamReader that uses the default charset.
  68      *
  69      * @param  in   An InputStream
  70      */
  71     public InputStreamReader(InputStream in) {
  72         super(in);
  73         try {
  74             sd = StreamDecoder.forInputStreamReader(in, this, (String)null); // ## check lock object
  75         } catch (UnsupportedEncodingException e) {
  76             // The default encoding should always be available
  77             throw new Error(e);
  78         }
  79     }




  39  *
  40  * <p> Each invocation of one of an InputStreamReader's read() methods may
  41  * cause one or more bytes to be read from the underlying byte-input stream.
  42  * To enable the efficient conversion of bytes to characters, more bytes may
  43  * be read ahead from the underlying stream than are necessary to satisfy the
  44  * current read operation.
  45  *
  46  * <p> For top efficiency, consider wrapping an InputStreamReader within a
  47  * BufferedReader.  For example:
  48  *
  49  * <pre>
  50  * BufferedReader in
  51  *   = new BufferedReader(new InputStreamReader(System.in));
  52  * </pre>
  53  *
  54  * @see BufferedReader
  55  * @see InputStream
  56  * @see java.nio.charset.Charset
  57  *
  58  * @author      Mark Reinhold
  59  * @since       1.1
  60  */
  61 
  62 public class InputStreamReader extends Reader {
  63 
  64     private final StreamDecoder sd;
  65 
  66     /**
  67      * Creates an InputStreamReader that uses the default charset.
  68      *
  69      * @param  in   An InputStream
  70      */
  71     public InputStreamReader(InputStream in) {
  72         super(in);
  73         try {
  74             sd = StreamDecoder.forInputStreamReader(in, this, (String)null); // ## check lock object
  75         } catch (UnsupportedEncodingException e) {
  76             // The default encoding should always be available
  77             throw new Error(e);
  78         }
  79     }