POIFSFileSystem fs = new POIFSFileSystem();
DirectoryEntry directory = fs.getRoot();
directory.createDocument("WordDocument", new ByteArrayInputStream(content.getBytes()));
FileOutputStream out = new FileOutputStream(FileName);
fs.writeFilesystem(out);
out.close();
i'm creating (.doc) file using the above code. File created using the above code is opening in MicrosoftWord. But when i'm trying to open the same file in Jtextarea using the below code
WordExtractor extractor = null;
tabcount = e.jTabbedPane1.getSelectedIndex();
try {
FileInputStream fis = new FileInputStream(file.getAbsolutePath());
HWPFDocument document = new HWPFDocument(fis);
extractor = new WordExtractor(document);
String fileData = extractor.getText();
if (fileData != null) {
e.textAreas[tabcount].append(fileData);
}
} catch (Exception doc_error) {
System.out.println(doc_error);
}
It shows error : java.lang.ArrayIndexOutOfBoundsException: 4
but the file created using MicrosoftWord opened by above code.