List of usage examples for org.apache.poi POIDataSamples openResourceAsStream
public InputStream openResourceAsStream(String sampleFileName)
From source file:NewEmptyJUnitTest.java
protected void setUp() throws Exception { String filename = "test2.doc"; String filename2 = "test.doc"; filename3 = "excel_with_embeded.xls"; filename4 = "ThreeColHeadFoot.doc"; filename5 = "HeaderFooterUnicode.doc"; filename6 = "footnote.doc"; POIDataSamples docTests = POIDataSamples.getDocumentInstance(); extractor = new WordExtractor(docTests.openResourceAsStream(filename)); extractor2 = new WordExtractor(docTests.openResourceAsStream(filename2)); // Build splat'd out text version for (int i = 0; i < p_text1.length; i++) { p_text1_block += p_text1[i];// w ww.jav a 2s . c om } }
From source file:NewEmptyJUnitTest.java
/** * Tests that we can work with both {@link POIFSFileSystem} * and {@link NPOIFSFileSystem}// w w w .j a v a 2s . c o m */ public void testDifferentPOIFS() throws Exception { POIDataSamples docTests = POIDataSamples.getDocumentInstance(); // Open the two filesystems DirectoryNode[] files = new DirectoryNode[2]; files[0] = (new POIFSFileSystem(docTests.openResourceAsStream("test2.doc"))).getRoot(); NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(docTests.getFile("test2.doc")); files[1] = npoifsFileSystem.getRoot(); // Open directly for (DirectoryNode dir : files) { WordExtractor extractor = new WordExtractor(dir); assertEquals(p_text1_block, extractor.getText()); } // Open via a HWPFDocument for (DirectoryNode dir : files) { HWPFDocument doc = new HWPFDocument(dir); WordExtractor extractor = new WordExtractor(doc); assertEquals(p_text1_block, extractor.getText()); } npoifsFileSystem.close(); }