private byte[] writeXmpSegment(final byte[] xmpXmlData, final int start, final int length) throws IOException {
        final ByteArrayOutputStream os = new ByteArrayOutputStream();

        JpegConstants.XMP_IDENTIFIER.writeTo(os);
        os.write(xmpXmlData, start, length);

        return os.toByteArray();
    }
Reads a JPEG image, replaces the XMP XML and writes the result to a stream.

@param src    InputStream containing JPEG image data.
@param os     OutputStream to write the image to.
@param xmpXml String containing XMP XML.
@throws ImagingException if it fails to read or write the JFIF segments
@throws IOException      if it fails to read or write the data from the segments
src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java