Merge XML Strings in Java without File intermediary

67 Views Asked by At

I am currently using XInclude to merge XML files. However, I am moving these XMLs from a filesystem to a database where they are saved as Strings. What is the best way to merge these XML strings without using Files as an intermediary?

1

There are 1 best solutions below

2
On

You need to redirect input streams of the file to the output stream of the database. In order to merge input streams, just use java.io.SequenceInputStream(i1, i2)

new SequenceInputStream(new FileInputStream(xmlFile1), new FileInputStream(xmlFile2))
// use merged inputStream