com.bumptech.glide.util
Class ExceptionCatchingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.bumptech.glide.util.ExceptionCatchingInputStream
All Implemented Interfaces:
Closeable

public class ExceptionCatchingInputStream
extends InputStream

An InputStream that catches IOExceptions during read and skip calls and stores them so they can later be handled or thrown. This class is a workaround for a framework issue where exceptions during reads while decoding bitmaps in BitmapFactory can return partially decoded bitmaps. See https://github.com/bumptech/glide/issues/126.


Method Summary
 int available()
           
 void close()
           
 IOException getException()
           
 void mark(int readlimit)
           
 boolean markSupported()
           
static ExceptionCatchingInputStream obtain(InputStream toWrap)
           
 int read()
           
 int read(byte[] buffer)
           
 int read(byte[] buffer, int byteOffset, int byteCount)
           
 void release()
           
 void reset()
           
 long skip(long byteCount)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

obtain

public static ExceptionCatchingInputStream obtain(InputStream toWrap)

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

mark

public void mark(int readlimit)
Overrides:
mark in class InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStream

read

public int read(byte[] buffer)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] buffer,
                int byteOffset,
                int byteCount)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

reset

public void reset()
           throws IOException
Overrides:
reset in class InputStream
Throws:
IOException

skip

public long skip(long byteCount)
          throws IOException
Overrides:
skip in class InputStream
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

getException

public IOException getException()

release

public void release()