public static IByteSequence readAllBytesFromStream(InputStream inputStream,int capacity) throws IOException {
  try {
    final int BUFFER_SIZE=1024;
    byte[] buffer=new byte[BUFFER_SIZE];
    ByteArrayOutputStreamExt bytes=new ByteArrayOutputStreamExt(capacity);
    int read;
    while ((read=inputStream.read(buffer)) != EOF) {
      bytes.write(buffer,0,read);
    }
    return bytes;
  }
  finally {
    inputStream.close();
  }
}

public static IByteSequence readAllBytesFromStream ( InputStream inputStream , int capacity ) throws IOException { try { final int BUFFER_SIZE = 1024 ; byte [ ] buffer = new byte [ BUFFER_SIZE ] ; ByteArrayOutputStreamExt bytes = new ByteArrayOutputStreamExt ( capacity ) ; int read ; while ( ( read = inputStream . read ( buffer ) ) != EOF ) { bytes . write ( buffer , 0 , read ) ; } return bytes ; } finally { inputStream . close ( ) ; } }
reads and returns all bytes from given inputstream until an eof is read . closes inputstream afterwards . bytearray buffer is initialized to given capacity .
