code: public static byte[] loadBytesFromStream(InputStream stream) {
  		try {
  			BufferedInputStream bis = new BufferedInputStream(stream);
  			byte[] theData = new byte[10000000];
  			int dataReadSoFar = 0;
  			byte[] buffer = new byte[1024];
  			int read = 0;
  			while ((read = bis.read(buffer)) != -1) {
  				System.arraycopy(buffer, 0, theData, dataReadSoFar, read);
  				dataReadSoFar += read;
  			}
  			bis.close();
  			// Resize to actual data read
  			byte[] returnData = new byte[dataReadSoFar];
  			System.arraycopy(theData, 0, returnData, 0, dataReadSoFar);
  			return returnData;
  		}
  		catch (IOException e) {
  			throw new RuntimeException(e);
  		}
  	}
docs: Load all the byte data from an input stream.
  
  @param stream the input stream from which to read
  @return a byte array containing all the data from the stream