Convert a word document to inputstream with aspose java

HI Team,

I had a requirement of merging two inputstreams of word documents with aspose java
for that I am using
d1 = new com.aspose.words.Document(inputStream1);;
d2 = new com.aspose.words.Document(inputStream2);

d1.appendDocument(d2, ImportFormatMode.KEEP_SOURCE_FORMATTING);

with this I want to return d1 as inputstream

Please guide me through

@kmehta,

Please try using the following code:

InputStream in1 = new FileInputStream("E:\\temp\\in1.docx");
InputStream in2 = new FileInputStream("E:\\temp\\in2.docx");

Document doc1 = new Document(in1);
Document doc2 = new Document(in2);

doc1.appendDocument(doc2, ImportFormatMode.KEEP_SOURCE_FORMATTING);

OutputStream out = new FileOutputStream("E:\\temp\\out.docx");
doc1.save(out, SaveFormat.DOCX); 

Hope, this helps.

It worked
Thank you