Reputation: 39
Using:
XWPFDocument document = new XWPFDocument();
How do I assign it so it doesn't overwrite the file if it already exists?
Upvotes: 2
Views: 4370
Reputation: 48376
The following will create a brand new, empty XWPF Word Document to work with:
XWPFDocument document = new XWPFDocument();
Whereas this will open up an existing one for editing:
XWPFDocument document = new XWPFDocument(OPCPackage.open("MyFile.docx"));
Or if you have an InputStream
rather than a file:
XWPFDocument document = new XWPFDocument(inputStream);
Upvotes: 5