public int read(final InputStream is,final int contentLength){
  if (is != null) {
    try {
      final int capacity=(contentLength > 0) ? (contentLength + 4096) : 4096;
      final ByteArrayOutputStream buffer=new ByteArrayOutputStream(capacity);
      int nRead;
      final byte[] data=new byte[16384];
      while ((nRead=is.read(data,0,data.length)) != -1) {
        buffer.write(data,0,nRead);
      }
      buffer.flush();
      read(buffer.toByteArray());
    }
 catch (    final IOException e) {
      Log.w(TAG,"Error reading data from stream",e);
    }
  }
 else {
    status=STATUS_OPEN_ERROR;
  }
  try {
    is.close();
  }
 catch (  final Exception e) {
    Log.w(TAG,"Error closing stream",e);
  }
  return status;
}

public int read ( final InputStream is , final int contentLength ) { if ( is != null ) { try { final int capacity = ( contentLength > 0 ) ? ( contentLength + 4096 ) : 4096 ; final ByteArrayOutputStream buffer = new ByteArrayOutputStream ( capacity ) ; int nRead ; final byte [ ] data = new byte [ 16384 ] ; while ( ( nRead = is . read ( data , 0 , data . length ) ) != - 1 ) { buffer . write ( data , 0 , nRead ) ; } buffer . flush ( ) ; read ( buffer . toByteArray ( ) ) ; } catch ( final IOException e ) { Log . w ( TAG , "Error reading data from stream" , e ) ; } } else { status = STATUS_OPEN_ERROR ; } try { is . close ( ) ; } catch ( final Exception e ) { Log . w ( TAG , "Error closing stream" , e ) ; } return status ; }
reads gif image from stream
