use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.
the class TestOutlookTextExtractor method testConstructors.
@Test
public void testConstructors() throws Exception {
FileInputStream fis = new FileInputStream(samples.getFile("simple_test_msg.msg"));
OutlookTextExtactor ext = new OutlookTextExtactor(fis);
String inp = ext.getText();
ext.close();
fis.close();
NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
ext = new OutlookTextExtactor(poifs);
String poifsTxt = ext.getText();
ext.close();
poifs.close();
fis = new FileInputStream(samples.getFile("simple_test_msg.msg"));
ext = new OutlookTextExtactor(new MAPIMessage(fis));
String mapi = ext.getText();
ext.close();
fis.close();
assertEquals(inp, poifsTxt);
assertEquals(inp, mapi);
}
use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.
the class TestReadAllFiles method readCustomPropertiesFromFiles.
/**
* <p>Tests the simplified custom properties by reading them from the
* available test files.</p>
*
* @throws Throwable if anything goes wrong.
*/
@Test
public void readCustomPropertiesFromFiles() throws Exception {
/* Read a test document <em>doc</em> into a POI filesystem. */
NPOIFSFileSystem poifs = new NPOIFSFileSystem(file);
try {
/*
* If there is a document summry information stream, read it from
* the POI filesystem, else create a new one.
*/
DocumentSummaryInformation dsi = TestWriteWellKnown.getDocumentSummaryInformation(poifs);
if (dsi == null) {
dsi = PropertySetFactory.newDocumentSummaryInformation();
}
final CustomProperties cps = dsi.getCustomProperties();
if (cps == null) {
/* The document does not have custom properties. */
return;
}
for (CustomProperty cp : cps.properties()) {
assertNotNull(cp.getName());
assertNotNull(cp.getValue());
}
} finally {
poifs.close();
}
}
use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.
the class TestRVA method data.
@Parameters(name = "{1}")
public static Collection<Object[]> data() throws Exception {
poifs = new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("testRVA.xls"), true);
workbook = new HSSFWorkbook(poifs);
sheet = workbook.getSheetAt(0);
List<Object[]> data = new ArrayList<Object[]>();
for (int rowIdx = 0; true; rowIdx++) {
HSSFRow row = sheet.getRow(rowIdx);
if (row == null) {
break;
}
HSSFCell cell = row.getCell(0);
if (cell == null || cell.getCellTypeEnum() == CellType.BLANK) {
break;
}
String formula = cell.getCellFormula();
data.add(new Object[] { cell, formula });
}
return data;
}
use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.
the class OldExcelExtractor method open.
private void open(InputStream biffStream) throws IOException {
BufferedInputStream bis = (biffStream instanceof BufferedInputStream) ? (BufferedInputStream) biffStream : new BufferedInputStream(biffStream, 8);
if (NPOIFSFileSystem.hasPOIFSHeader(bis)) {
NPOIFSFileSystem poifs = new NPOIFSFileSystem(bis);
try {
open(poifs);
} finally {
poifs.close();
}
} else {
ris = new RecordInputStream(bis);
toClose = bis;
prepare();
}
}
use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.
the class HWPFDocument method write.
/**
* Writes out the word file that is represented by an instance of this class.
*
* For better performance when writing to files, use {@link #write(File)}.
* If {@code stream} has a high cost/latency associated with each written byte,
* consider wrapping the OutputStream in a {@link java.io.BufferedOutputStream}
* to improve write performance.
*
* @param out The OutputStream to write to.
* @throws IOException If there is an unexpected IOException from the passed
* in OutputStream.
*/
public void write(OutputStream out) throws IOException {
NPOIFSFileSystem pfs = new NPOIFSFileSystem();
write(pfs, true);
pfs.writeFilesystem(out);
}
Aggregations