Mercurial Hosting > luan
diff src/goodjava/io/BufferedInputStream.java @ 1494:91c167099462
more io
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 03 May 2020 11:51:31 -0600 |
parents | fe237d72b234 |
children |
line wrap: on
line diff
--- a/src/goodjava/io/BufferedInputStream.java Sun May 03 00:12:15 2020 -0600 +++ b/src/goodjava/io/BufferedInputStream.java Sun May 03 11:51:31 2020 -0600 @@ -6,7 +6,6 @@ package goodjava.io; import java.io.InputStream; -import java.io.FilterInputStream; import java.io.IOException; /** @@ -22,7 +21,7 @@ * @author Arthur van Hoff * @since JDK1.0 */ -public final class BufferedInputStream extends FilterInputStream { +public final class BufferedInputStream extends NoMarkInputStream { private final byte buf[]; /** @@ -83,14 +82,13 @@ /** * Fills the buffer with more data. - * Assumes that it is being called by a synchronized method. * This method also assumes that all data has already been read in, * hence pos > count. */ private void fill() throws IOException { pos = 0; count = 0; - int n = super.read(buf, 0, buf.length); + int n = in.read(buf, 0, buf.length); if (n > 0) count = n; } @@ -107,7 +105,7 @@ * or an I/O error occurs. * @see java.io.FilterInputStream#in */ - public synchronized int read() throws IOException { + public int read() throws IOException { if (pos >= count) { fill(); if (pos >= count) @@ -133,7 +131,7 @@ off += cnt; } if (len >= buf.length) { - return cnt + Math.max( 0, super.read(b, off, len) ); + return cnt + Math.max( 0, in.read(b, off, len) ); } fill(); if (count <= 0) @@ -143,7 +141,7 @@ return cnt + len; } - public synchronized int read(byte[] b, int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { if( len == 0 ) return 0; int n = read1(b,off,len); @@ -159,7 +157,7 @@ * invoking its {@link #close()} method, or an * I/O error occurs. */ - public synchronized long skip(long n) throws IOException { + public long skip(long n) throws IOException { if( n <= 0 ) return 0; long skipped = 0; @@ -171,7 +169,7 @@ if( n == 0 ) return skipped; } - return skipped + super.skip(n); + return skipped + in.skip(n); } /** @@ -191,22 +189,12 @@ * invoking its {@link #close()} method, * or an I/O error occurs. */ - public synchronized int available() throws IOException { + public int available() throws IOException { int n = count - pos; - int avail = super.available(); + int avail = in.available(); return n > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : n + avail; } - public void mark(int readlimit) {} - - public void reset() throws IOException { - throw new IOException("mark/reset not supported"); - } - - public boolean markSupported() { - return false; - } - }