use of org.apache.poi.poifs.filesystem.OPOIFSFileSystem in project poi by apache.
the class TestPOIDocumentMain method WriteReadProperties.
@Test
public void WriteReadProperties() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// Write them out
NPOIFSFileSystem outFS = new NPOIFSFileSystem();
doc.readProperties();
doc.writeProperties(outFS);
outFS.writeFilesystem(baos);
// Create a new version
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
OPOIFSFileSystem inFS = new OPOIFSFileSystem(bais);
// Check they're still there
POIDocument doc3 = new HPSFPropertiesOnlyDocument(inFS);
doc3.readProperties();
// Delegate test
readPropertiesHelper(doc3);
doc3.close();
}
use of org.apache.poi.poifs.filesystem.OPOIFSFileSystem in project poi by apache.
the class TestExtractor method testDifferentPOIFS.
/**
* Tests that we can work with both {@link POIFSFileSystem}
* and {@link NPOIFSFileSystem}
*/
@SuppressWarnings("resource")
@Test
public void testDifferentPOIFS() throws IOException {
// Open the two filesystems
File pptFile = slTests.getFile("basic_test_ppt_file.ppt");
InputStream is1 = new FileInputStream(pptFile);
OPOIFSFileSystem opoifs = new OPOIFSFileSystem(is1);
is1.close();
NPOIFSFileSystem npoifs = new NPOIFSFileSystem(pptFile);
DirectoryNode[] files = { opoifs.getRoot(), npoifs.getRoot() };
// Open directly
for (DirectoryNode dir : files) {
PowerPointExtractor extractor = new PowerPointExtractor(dir);
assertEquals(expectText, extractor.getText());
}
// Open via a HSLFSlideShow
for (DirectoryNode dir : files) {
HSLFSlideShowImpl slideshow = new HSLFSlideShowImpl(dir);
PowerPointExtractor extractor = new PowerPointExtractor(slideshow);
assertEquals(expectText, extractor.getText());
extractor.close();
slideshow.close();
}
npoifs.close();
}
Aggregations