/// Reads up to {@code length} bytes from the input stream, and returns the bytes read. public static byte[] ToByteArray(Stream stream, int length) ByteArrayOutputStream baos = new ...