You could just use the XSLT identity template. But even that doesn't guarantee that the output file will be byte-for-byte identical to the input file; for example the process might have normalized an unnormalized attribute value, or it might have chosen to use double quotes around attribute values where the input had single quotes.
So why not just use ordinary
Java code which ignores the XML aspect of the file entirely and just copies the bytes from the input to the output?