public static final byte[] inputStreamToBuffer(final InputStream iStream,final int offset){
  try {
    int i;
    final ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream(1024);
    byte[] buffer=new byte[1024];
    if (offset > 0) {
      byte[] discard=new byte[offset];
      iStream.read(discard);
      discard=null;
    }
    while ((i=iStream.read(buffer)) != -1) {
      byteArrayOutputStream.write(buffer,0,i);
    }
    iStream.close();
    return byteArrayOutputStream.toByteArray();
  }
 catch (  final IOException e) {
    if (Cfg.EXCEPTION) {
      Check.log(e);
    }
    if (Cfg.DEBUG) {
      Check.log(e);
    }
    if (Cfg.DEBUG) {
      Check.log(TAG + " IOException() caught in Utils.RawResourceToBuffer()");
    }
    return null;
  }
}

public static final byte [ ] inputStreamToBuffer ( final InputStream iStream , final int offset ) { try { int i ; final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ( 1024 ) ; byte [ ] buffer = new byte [ 1024 ] ; if ( offset > 0 ) { byte [ ] discard = new byte [ offset ] ; iStream . read ( discard ) ; discard = null ; } while ( ( i = iStream . read ( buffer ) ) != - 1 ) { byteArrayOutputStream . write ( buffer , 0 , i ) ; } iStream . close ( ) ; return byteArrayOutputStream . toByteArray ( ) ; } catch ( final IOException e ) { if ( Cfg . EXCEPTION ) { Check . log ( e ) ; } if ( Cfg . DEBUG ) { Check . log ( e ) ; } if ( Cfg . DEBUG ) { Check . log ( TAG + " IOException() caught in Utils.RawResourceToBuffer()" ) ; } return null ; } }
converts an inputstream into a buffer .
