Open Existing Documents in Apache POI and Aspose.Words

Aspose.Words - Open Existing Document

Pass a file name as a string to the Document constructor that accepts a string to open an existing document from a file

Java

// The path to the documents directory.
String dataDir = Utils.getDataDir(AsposeOpenExistingDoc.class);

Document doc = new Document(dataDir + "document.doc");

Apache POI HWPF XWPF - Open Existing Document

FileInputStream is passed to the constructor of HWPFDocument to open an existing document.

Java

// The path to the documents directory.
String dataDir = Utils.getDataDir(ApacheOpenExistingDoc.class);

HWPFDocument doc = new HWPFDocument(new FileInputStream(
                dataDir + "document.doc"));

Download Running Code

Download Sample Code