@Override public int read() throws IOException { if (isExternallyClosed) { /* * The API does not permit reading after the stream * has been closed. Mimic that behavior. */ throw new IOException(); } if (isWrappedStreamClosed) { /* * We have closed the wrapped stream, because it * returned a -1 from read, but the stream has not * been externally closed yet. So continue returning * the end-of-stream indiciator. */ return -1; } final int result = wrappedStream.read(); if (result == -1) { /* * We've exhausted the wrapped stream, so close it * internally. */ closeInternally(); } return result; }
@Override public int read() throws IOException { if (isExternallyClosed) { /* * The API does not permit reading after the stream * has been closed. Mimic that behavior. */ throw new IOException(); } if (isWrappedStreamClosed) { /* * We have closed the wrapped stream, because it * returned a -1 from read, but the stream has not * been externally closed yet. So continue returning * the end-of-stream indiciator. */ return -1; } final int result = wrappedStream.read(); if (result == -1) { /* * We've exhausted the wrapped stream, so close it * internally. */ closeInternally(); } return result; }
@Override public int read() throws IOException { if (isExternallyClosed) { /* * The API does not permit reading after the stream * has been closed. Mimic that behavior. */ throw new IOException(); } if (isWrappedStreamClosed) { /* * We have closed the wrapped stream, because it * returned a -1 from read, but the stream has not * been externally closed yet. So continue returning * the end-of-stream indiciator. */ return -1; } final int result = wrappedStream.read(); if (result == -1) { /* * We've exhausted the wrapped stream, so close it * internally. */ closeInternally(); } return result; }
@Override public void close() throws IOException { closeInternally(); isExternallyClosed = true; }
@Override public void close() throws IOException { closeInternally(); isExternallyClosed = true; }
@Override public void close() throws IOException { closeInternally(); isExternallyClosed = true; }