diff src/goodjava/io/BufferedInputStream.java @ 1483:97740900c820

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 25 Apr 2020 10:31:49 -0600
parents 1f41e5921090
children fe237d72b234
line wrap: on
line diff
--- a/src/goodjava/io/BufferedInputStream.java	Fri Apr 24 21:20:42 2020 -0600
+++ b/src/goodjava/io/BufferedInputStream.java	Sat Apr 25 10:31:49 2020 -0600
@@ -23,9 +23,7 @@
  * @since   JDK1.0
  */
 public final class BufferedInputStream extends FilterInputStream {
-	private static int DEFAULT_BUFFER_SIZE = 8192;
 	private final byte buf[];
-	private boolean isClosed = false;
 
 	/**
 	 * The index one greater than the index of the last valid byte in
@@ -55,11 +53,6 @@
 	 */
 	private int pos;
 
-	private void checkClosed() throws IOException {
-		if (isClosed)
-			throw new IOException("Stream closed");
-	}
-
 	/**
 	 * Creates a <code>BufferedInputStream</code>
 	 * and saves its  argument, the input stream
@@ -69,7 +62,7 @@
 	 * @param   in   the underlying input stream.
 	 */
 	public BufferedInputStream(InputStream in) {
-		this(in, DEFAULT_BUFFER_SIZE);
+		this(in, 8192);
 	}
 
 	/**
@@ -115,7 +108,6 @@
 	 * @see        java.io.FilterInputStream#in
 	 */
 	public synchronized int read() throws IOException {
-		checkClosed();
 		if (pos >= count) {
 			fill();
 			if (pos >= count)
@@ -129,7 +121,6 @@
 	 * stream at most once if necessary.
 	 */
 	public synchronized int read(byte[] b, int off, int len) throws IOException {
-		checkClosed();
 		int avail = count - pos;
 		if (avail <= 0) {
 			/* If the requested length is at least as large as the buffer, do not bother to copy the
@@ -158,7 +149,6 @@
 	 *                          I/O error occurs.
 	 */
 	public synchronized long skip(long n) throws IOException {
-		checkClosed();
 		long avail = count - pos;
 		if (avail <= 0) {
 			return super.skip(n);
@@ -203,17 +193,4 @@
 		return false;
 	}
 
-	/**
-	 * Closes this input stream and releases any system resources
-	 * associated with the stream.
-	 * Once the stream has been closed, further read(), available(), reset(),
-	 * or skip() invocations will throw an IOException.
-	 * Closing a previously closed stream has no effect.
-	 *
-	 * @exception  IOException  if an I/O error occurs.
-	 */
-	public synchronized void close() throws IOException {
-		isClosed = true;
-		super.close();
-	}
 }