src/share/classes/java/io/PushbackInputStream.java

Print this page




  68 
  69     /**
  70      * Check to make sure that this stream has not been closed
  71      */
  72     private void ensureOpen() throws IOException {
  73         if (in == null)
  74             throw new IOException("Stream closed");
  75     }
  76 
  77     /**
  78      * Creates a <code>PushbackInputStream</code>
  79      * with a pushback buffer of the specified <code>size</code>,
  80      * and saves its  argument, the input stream
  81      * <code>in</code>, for later use. Initially,
  82      * there is no pushed-back byte  (the field
  83      * <code>pushBack</code> is initialized to
  84      * <code>-1</code>).
  85      *
  86      * @param  in    the input stream from which bytes will be read.
  87      * @param  size  the size of the pushback buffer.
  88      * @exception IllegalArgumentException if size is <= 0
  89      * @since  JDK1.1
  90      */
  91     public PushbackInputStream(InputStream in, int size) {
  92         super(in);
  93         if (size <= 0) {
  94             throw new IllegalArgumentException("size <= 0");
  95         }
  96         this.buf = new byte[size];
  97         this.pos = size;
  98     }
  99 
 100     /**
 101      * Creates a <code>PushbackInputStream</code>
 102      * and saves its  argument, the input stream
 103      * <code>in</code>, for later use. Initially,
 104      * there is no pushed-back byte  (the field
 105      * <code>pushBack</code> is initialized to
 106      * <code>-1</code>).
 107      *
 108      * @param   in   the input stream from which bytes will be read.




  68 
  69     /**
  70      * Check to make sure that this stream has not been closed
  71      */
  72     private void ensureOpen() throws IOException {
  73         if (in == null)
  74             throw new IOException("Stream closed");
  75     }
  76 
  77     /**
  78      * Creates a <code>PushbackInputStream</code>
  79      * with a pushback buffer of the specified <code>size</code>,
  80      * and saves its  argument, the input stream
  81      * <code>in</code>, for later use. Initially,
  82      * there is no pushed-back byte  (the field
  83      * <code>pushBack</code> is initialized to
  84      * <code>-1</code>).
  85      *
  86      * @param  in    the input stream from which bytes will be read.
  87      * @param  size  the size of the pushback buffer.
  88      * @exception IllegalArgumentException if {@code size <= 0}
  89      * @since  JDK1.1
  90      */
  91     public PushbackInputStream(InputStream in, int size) {
  92         super(in);
  93         if (size <= 0) {
  94             throw new IllegalArgumentException("size <= 0");
  95         }
  96         this.buf = new byte[size];
  97         this.pos = size;
  98     }
  99 
 100     /**
 101      * Creates a <code>PushbackInputStream</code>
 102      * and saves its  argument, the input stream
 103      * <code>in</code>, for later use. Initially,
 104      * there is no pushed-back byte  (the field
 105      * <code>pushBack</code> is initialized to
 106      * <code>-1</code>).
 107      *
 108      * @param   in   the input stream from which bytes will be read.