public static byte[] getBytesFromStream(InputStream inputStream, int expectedLength)
			throws IOException {
		byte[] buf = new byte[expectedLength];
		int bufRemaining = expectedLength;

		int bytesCopied = 0;
		int bytesRead = 0;
		while (bufRemaining > 0 &&
			(bytesRead = inputStream.read(buf, bytesCopied, bufRemaining)) > 0) {
			bytesCopied += bytesRead;
			bufRemaining -= bytesRead;
		}

		if (bytesCopied != expectedLength) {
			throw new IOException("Could only read " + bytesCopied +
				" bytes from input stream when trying to read " + expectedLength + " bytes.");
		}

		return buf;
	}
Reads the number of bytes indicated by the expectedLength from the input stream and returns
them in a byte array.
@param inputStream the input stream
@param expectedLength the number of bytes to be read
@return an array of bytes, that is the expectedLength, that was read from the stream.
@throws IOException if the "expectedLength" number of bytes can't be read from the input stream.
Ghidra/Framework/Utility/src/main/java/utilities/util/FileUtilities.java