public static byte[] getByteContent(InputStream inputStream)
            throws IOException {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream(
                16 * 1024);
        byte[] buffer = new byte[1024];
        int byteCount = -1;
        byte[] data = null;

        // Read the byte content into the output stream first
        while ((byteCount = inputStream.read(buffer)) > 0) {
            outputStream.write(buffer, 0, byteCount);
        }

        // Set data with byte content from stream
        data = outputStream.toByteArray();

        // Release resources
        outputStream.close();

        return data;
    }
Takes an InputStream and returns the complete byte content of it

@param inputStream
           The input stream to read from
@return The byte array containing the data from the input stream
@throws java.io.IOException
            thrown if there is a problem reading from the input stream
            provided
jme3-core/src/plugins/java/com/jme3/export/binary/ByteUtils.java