class Misc {

	public static byte[] streamToBytes(InputStream inputStream) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		byte[] buffer = new byte[1024];
		while (true) {
			int r = inputStream.read(buffer);
			if (r == -1) {
				break;
			}
			out.write(buffer, 0, r);
		}

		return out.toByteArray();
	}

}