Search in sources :

Example 46 with NPOIFSFileSystem

use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.

the class EFBiffViewer method run.

public void run() throws IOException {
    NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(file), true);
    try {
        InputStream din = BiffViewer.getPOIFSInputStream(fs);
        try {
            HSSFRequest req = new HSSFRequest();
            req.addListenerForAllRecords(new HSSFListener() {

                public void processRecord(Record rec) {
                    System.out.println(rec);
                }
            });
            HSSFEventFactory factory = new HSSFEventFactory();
            factory.processEvents(req, din);
        } finally {
            din.close();
        }
    } finally {
        fs.close();
    }
}
Also used : HSSFEventFactory(org.apache.poi.hssf.eventusermodel.HSSFEventFactory) NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) InputStream(java.io.InputStream) HSSFRequest(org.apache.poi.hssf.eventusermodel.HSSFRequest) Record(org.apache.poi.hssf.record.Record) HSSFListener(org.apache.poi.hssf.eventusermodel.HSSFListener) File(java.io.File)

Example 47 with NPOIFSFileSystem

use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.

the class HPSFPropertiesOnlyDocument method write.

/**
     * Write out, with any properties changes, but nothing else
     */
public void write(OutputStream out) throws IOException {
    NPOIFSFileSystem fs = new NPOIFSFileSystem();
    try {
        write(fs);
        fs.writeFilesystem(out);
    } finally {
        fs.close();
    }
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem)

Example 48 with NPOIFSFileSystem

use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.

the class HPSFPropertiesOnlyDocument method write.

/**
     * Write out to the currently open file the properties changes, but nothing else
     */
public void write() throws IOException {
    NPOIFSFileSystem fs = getDirectory().getFileSystem();
    validateInPlaceWritePossible();
    writeProperties(fs, null);
    fs.writeFilesystem();
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem)

Example 49 with NPOIFSFileSystem

use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.

the class OutlookTextExtactor method main.

public static void main(String[] args) throws Exception {
    for (String filename : args) {
        NPOIFSFileSystem poifs = null;
        OutlookTextExtactor extractor = null;
        try {
            poifs = new NPOIFSFileSystem(new File(filename));
            extractor = new OutlookTextExtactor(poifs);
            System.out.println(extractor.getText());
        } finally {
            if (extractor != null)
                extractor.close();
            if (poifs != null)
                poifs.close();
        }
    }
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) File(java.io.File)

Example 50 with NPOIFSFileSystem

use of org.apache.poi.poifs.filesystem.NPOIFSFileSystem in project poi by apache.

the class TestBugs method bug51461.

/**
     * File with exactly 256 data blocks (+header block)
     *  shouldn't break on POIFS loading
     */
@SuppressWarnings("resource")
@Test
public void bug51461() throws Exception {
    byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51461.xls");
    HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem(new ByteArrayInputStream(data)).getRoot(), false);
    HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new NPOIFSFileSystem(new ByteArrayInputStream(data)).getRoot(), false);
    assertEquals(2, wbPOIFS.getNumberOfSheets());
    assertEquals(2, wbNPOIFS.getNumberOfSheets());
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) ByteArrayInputStream(java.io.ByteArrayInputStream) OPOIFSFileSystem(org.apache.poi.poifs.filesystem.OPOIFSFileSystem) POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) Test(org.junit.Test)

Aggregations

NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)101 Test (org.junit.Test)57 File (java.io.File)35 InputStream (java.io.InputStream)26 ByteArrayInputStream (java.io.ByteArrayInputStream)19 ByteArrayOutputStream (java.io.ByteArrayOutputStream)14 MAPIMessage (org.apache.poi.hsmf.MAPIMessage)14 FileOutputStream (java.io.FileOutputStream)12 TempFile (org.apache.poi.util.TempFile)12 FileInputStream (java.io.FileInputStream)11 OPOIFSFileSystem (org.apache.poi.poifs.filesystem.OPOIFSFileSystem)10 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)10 DocumentSummaryInformation (org.apache.poi.hpsf.DocumentSummaryInformation)9 DirectoryNode (org.apache.poi.poifs.filesystem.DirectoryNode)9 IOException (java.io.IOException)8 OutputStream (java.io.OutputStream)8 SummaryInformation (org.apache.poi.hpsf.SummaryInformation)7 TikaInputStream (org.apache.tika.io.TikaInputStream)6 AgileDecryptor (org.apache.poi.poifs.crypt.agile.AgileDecryptor)5 DirectoryEntry (org.apache.poi.poifs.filesystem.DirectoryEntry)5