72 */ 73 private void ensureOpen() throws IOException { 74 if (in == null) 75 throw new IOException("Stream closed"); 76 } 77 78 /** 79 * Creates a <code>PushbackInputStream</code> 80 * with a pushback buffer of the specified <code>size</code>, 81 * and saves its argument, the input stream 82 * <code>in</code>, for later use. Initially, 83 * the pushback buffer is empty. 84 * 85 * @param in the input stream from which bytes will be read. 86 * @param size the size of the pushback buffer. 87 * @exception IllegalArgumentException if {@code size <= 0} 88 * @since 1.1 89 */ 90 public PushbackInputStream(InputStream in, int size) { 91 super(in); 92 if (size <= 0) { 93 throw new IllegalArgumentException("size <= 0"); 94 } 95 this.buf = new byte[size]; 96 this.pos = size; 97 } 98 99 /** 100 * Creates a <code>PushbackInputStream</code> 101 * with a 1-byte pushback buffer, and saves its argument, the input stream 102 * <code>in</code>, for later use. Initially, 103 * the pushback buffer is empty. 104 * 105 * @param in the input stream from which bytes will be read. 106 */ 107 public PushbackInputStream(InputStream in) { 108 this(in, 1); 109 } 110 111 /** | 72 */ 73 private void ensureOpen() throws IOException { 74 if (in == null) 75 throw new IOException("Stream closed"); 76 } 77 78 /** 79 * Creates a <code>PushbackInputStream</code> 80 * with a pushback buffer of the specified <code>size</code>, 81 * and saves its argument, the input stream 82 * <code>in</code>, for later use. Initially, 83 * the pushback buffer is empty. 84 * 85 * @param in the input stream from which bytes will be read. 86 * @param size the size of the pushback buffer. 87 * @exception IllegalArgumentException if {@code size <= 0} 88 * @since 1.1 89 */ 90 public PushbackInputStream(InputStream in, int size) { 91 super(in); 92 if (in == null) { 93 throw new NullPointerException(); 94 } 95 if (size <= 0) { 96 throw new IllegalArgumentException("size <= 0"); 97 } 98 this.buf = new byte[size]; 99 this.pos = size; 100 } 101 102 /** 103 * Creates a <code>PushbackInputStream</code> 104 * with a 1-byte pushback buffer, and saves its argument, the input stream 105 * <code>in</code>, for later use. Initially, 106 * the pushback buffer is empty. 107 * 108 * @param in the input stream from which bytes will be read. 109 */ 110 public PushbackInputStream(InputStream in) { 111 this(in, 1); 112 } 113 114 /** |