try
{
String filename = System.getProperty("HWPF.testdata.path");
if (filename == null)
{
filename = "c:";
}
filename = filename + "/test.doc";
POIFSFileSystem filesystem = new POIFSFileSystem(new FileInputStream(
new File(filename)));
DocumentEntry documentProps =
(DocumentEntry) filesystem.getRoot().getEntry("WordDocument");
_mainStream = new byte[documentProps.getSize()];
filesystem.createDocumentInputStream("WordDocument").read(_mainStream);
// use the fib to determine the name of the table stream.
_fib = new FileInformationBlock(_mainStream);
String name = "0Table";
if (_fib.isFWhichTblStm())
{
name = "1Table";
}
// read in the table stream.
DocumentEntry tableProps =
(DocumentEntry) filesystem.getRoot().getEntry(name);
_tableStream = new byte[tableProps.getSize()];
filesystem.createDocumentInputStream(name).read(_tableStream);
_fib.fillVariableFields(_mainStream, _tableStream);
}
catch (Throwable t)
{
t.printStackTrace();
}