-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable
public final class ExceptionPassthroughInputStream extends InputStream
An InputStream that catches, stores and rethrows IOExceptions during read and skip calls. This allows users of this API to handle the exception at a higher level if the exception is swallowed by some intermediate library. This class is a workaround for a framework issue where exceptions during reads while decoding bitmaps in can return partially decoded bitmaps.
Unlike the deprecated ExceptionCatchingInputStream, this class will both store and re-throw any IOExceptions. Rethrowing works around bugs in wrapping streams that may not fully obey the stream contract. This is really only useful if some middle layer is going to catch the exception (like BitmapFactory) but we want to propagate the exception instead.
-
-
Field Summary
Fields Modifier and Type Field Description private IOExceptionexception
-
Method Summary
Modifier and Type Method Description IOExceptiongetException()static ExceptionPassthroughInputStreamobtain(@NonNull() InputStream toWrap)intavailable()voidclose()voidmark(int readLimit)booleanmarkSupported()intread()intread(Array<byte> buffer)intread(Array<byte> buffer, int byteOffset, int byteCount)synchronized voidreset()longskip(long byteCount)voidrelease()-
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getException
@Nullable() IOException getException()
-
obtain
@NonNull() static ExceptionPassthroughInputStream obtain(@NonNull() InputStream toWrap)
-
available
int available()
-
close
void close()
-
mark
void mark(int readLimit)
-
markSupported
boolean markSupported()
-
read
int read()
-
reset
synchronized void reset()
-
skip
long skip(long byteCount)
-
release
void release()
-
-
-
-