Search in sources :

Example 91 with NPOIFSFileSystem

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

the class TestPOIFSDump method testFailToWrite.

@Test(expected = IndexOutOfBoundsException.class)
public void testFailToWrite() throws IOException {
    File dir = TempFile.createTempFile("TestPOIFSDump", ".tst");
    assertTrue("Had: " + dir, dir.exists());
    assertTrue("Had: " + dir, dir.delete());
    assertTrue("Had: " + dir, dir.mkdirs());
    FileInputStream is = new FileInputStream(TEST_FILE);
    NPOIFSFileSystem fs = new NPOIFSFileSystem(is);
    is.close();
    NPropertyTable props = fs.getPropertyTable();
    assertNotNull(props);
    // try with an invalid startBlock to trigger an exception
    // to validate that file-handles are closed properly
    POIFSDump.dump(fs, 999999999, "mini-stream", dir);
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) NPropertyTable(org.apache.poi.poifs.property.NPropertyTable) TempFile(org.apache.poi.util.TempFile) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 92 with NPOIFSFileSystem

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

the class HSSFWorkbook method write.

/**
     * Method write - write out this workbook to an {@link OutputStream}. Constructs
     * a new POI POIFSFileSystem, passes in the workbook binary representation and
     * writes it out.
     * 
     * If {@code stream} is a {@link java.io.FileOutputStream} on a networked drive
     * or 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 stream - the java OutputStream you wish to write the XLS to
     *
     * @exception IOException if anything can't be written.
     * @see org.apache.poi.poifs.filesystem.POIFSFileSystem
     */
@Override
public void write(OutputStream stream) throws IOException {
    NPOIFSFileSystem fs = new NPOIFSFileSystem();
    try {
        write(fs);
        fs.writeFilesystem(stream);
    } finally {
        fs.close();
    }
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem)

Example 93 with NPOIFSFileSystem

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

the class HDGFDiagram method main.

/**
	 * For testing only
	 */
public static void main(String[] args) throws Exception {
    NPOIFSFileSystem pfs = new NPOIFSFileSystem(new File(args[0]));
    HDGFDiagram hdgf = new HDGFDiagram(pfs);
    hdgf.debug();
    hdgf.close();
    pfs.close();
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) File(java.io.File)

Example 94 with NPOIFSFileSystem

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

the class VSDDumper method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.err.println("Use:");
        System.err.println("  VSDDumper <filename>");
        System.exit(1);
    }
    NPOIFSFileSystem poifs = new NPOIFSFileSystem(new File(args[0]));
    try {
        HDGFDiagram hdgf = new HDGFDiagram(poifs);
        PrintStream ps = System.out;
        ps.println("Opened " + args[0]);
        VSDDumper vd = new VSDDumper(ps, hdgf);
        vd.dumpFile();
    } finally {
        poifs.close();
    }
}
Also used : PrintStream(java.io.PrintStream) NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) HDGFDiagram(org.apache.poi.hdgf.HDGFDiagram) File(java.io.File)

Example 95 with NPOIFSFileSystem

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

the class HPBFDumper method main.

@SuppressWarnings("resource")
public static void main(String[] args) throws Exception {
    if (args.length < 1) {
        System.err.println("Use:");
        System.err.println("  HPBFDumper <filename>");
        System.exit(1);
    }
    HPBFDumper dump = new HPBFDumper(new NPOIFSFileSystem(new File(args[0])));
    System.out.println("Dumping " + args[0]);
    dump.dumpContents();
    dump.dumpEnvelope();
    dump.dumpEscher();
    dump.dump001CompObj(dump.fs.getRoot());
    dump.dumpQuill();
// Still to go:
//  (0x03)Internal
//  Objects
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) File(java.io.File)

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