Examples of POIFSReader


Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

         }
      };

      try
      {
         POIFSReader poiFSReader = new POIFSReader();
         poiFSReader.registerListener(readerListener, SummaryInformation.DEFAULT_STREAM_NAME);
         poiFSReader.read(is);
      }
      catch (POIRuntimeException e)
      {
         Throwable ex = e.getException();
         if (ex instanceof IOException)
View Full Code Here

Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

    public static POIFile[] readPOIFiles(final File poiFs,
                                         final String[] poiFiles)
        throws FileNotFoundException, IOException
    {
        final List files = new ArrayList();
        POIFSReader r = new POIFSReader();
        POIFSReaderListener pfl = new POIFSReaderListener()
        {
            public void processPOIFSReaderEvent(final POIFSReaderEvent event)
            {
                try
                {
                    final POIFile f = new POIFile();
                    f.setName(event.getName());
                    f.setPath(event.getPath());
                    final InputStream in = event.getStream();
                    final ByteArrayOutputStream out =
                        new ByteArrayOutputStream();
                    Util.copy(in, out);
                    out.close();
                    f.setBytes(out.toByteArray());
                    files.add(f);
                }
                catch (IOException ex)
                {
                    ex.printStackTrace();
                    throw new RuntimeException(ex.getMessage());
                }
            }
        };
        if (poiFiles == null)
            /* Register the listener for all POI files. */
            r.registerListener(pfl);
        else
            /* Register the listener for the specified POI files
             * only. */
            for (int i = 0; i < poiFiles.length; i++)
                r.registerListener(pfl, poiFiles[i]);

        /* Read the POI filesystem. */
        r.read(new FileInputStream(poiFs));
        POIFile[] result = new POIFile[files.size()];
        for (int i = 0; i < result.length; i++)
            result[i] = (POIFile) files.get(i);
        return result;
    }
View Full Code Here

Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

     */
    public static POIFile[] readPropertySets(final File poiFs)
        throws FileNotFoundException, IOException
    {
        final List files = new ArrayList(7);
        final POIFSReader r = new POIFSReader();
        POIFSReaderListener pfl = new POIFSReaderListener()
        {
            public void processPOIFSReaderEvent(final POIFSReaderEvent event)
            {
                try
                {
                    final POIFile f = new POIFile();
                    f.setName(event.getName());
                    f.setPath(event.getPath());
                    final InputStream in = event.getStream();
                    if (PropertySet.isPropertySetStream(in))
                    {
                        final ByteArrayOutputStream out =
                            new ByteArrayOutputStream();
                        Util.copy(in, out);
                        out.close();
                        f.setBytes(out.toByteArray());
                        files.add(f);
                    }
                }
                catch (Exception ex)
                {
                    ex.printStackTrace();
                    throw new RuntimeException(ex.getMessage());
                }
            }
        };

        /* Register the listener for all POI files. */
        r.registerListener(pfl);

        /* Read the POI filesystem. */
        r.read(new FileInputStream(poiFs));
        POIFile[] result = new POIFile[files.size()];
        for (int i = 0; i < result.length; i++)
            result[i] = (POIFile) files.get(i);
        return result;
    }
View Full Code Here

Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

            System.exit(1);
        }

        /* Read the origin POIFS using the eventing API. The real work is done
         * in the class CopyFile which is registered here as a POIFSReader. */
        final POIFSReader r = new POIFSReader();
        final CopyFile cf = new CopyFile(copyFileName);
        r.registerListener(cf);
        r.read(new FileInputStream(originalFileName));
       
        /* Write the new POIFS to disk. */
        cf.close();

        /* Read all documents from the original POI file system and compare them
View Full Code Here

Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

     */
    public static void main(final String[] args)
        throws IOException
    {
        final String filename = args[0];
        POIFSReader r = new POIFSReader();

        /* Register a listener for *all* documents. */
        r.registerListener(new MyPOIFSReaderListener());
        r.read(new FileInputStream(filename));
    }
View Full Code Here

Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

        for (int i = 0; i < args.length; i++)
        {
            final String filename = args[i];
            try
            {
                POIFSReader r = new POIFSReader();
                r.registerListener(new TreeReaderListener(filename, rootNode));
                r.read(new FileInputStream(filename));
                displayedFiles++;
            }
            catch (IOException ex)
            {
                System.err.println(filename + ": " + ex);
View Full Code Here

Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

     * @throws IOException if any I/O exception occurs.
     */
    public static void main(final String[] args) throws IOException
    {
        final String filename = args[0];
        POIFSReader r = new POIFSReader();
        r.registerListener(new MyPOIFSReaderListener(),
                           "\005SummaryInformation");
        r.read(new FileInputStream(filename));
    }
View Full Code Here

Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

        final String dstName = args[1];

        /* Read the origin POIFS using the eventing API. The real work is done
         * in the class ModifySICopyTheRest which is registered here as a
         * POIFSReader. */
        final POIFSReader r = new POIFSReader();
        final ModifySICopyTheRest msrl = new ModifySICopyTheRest(dstName);
        r.registerListener(msrl);
        r.read(new FileInputStream(srcName));
       
        /* Write the new POIFS to disk. */
        msrl.close();
    }
View Full Code Here

Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

                             SummaryInformation.DEFAULT_STREAM_NAME);
        poiFs.writeFilesystem(out);
        out.close();

        /* Read the POIFS: */
        final POIFSReader r = new POIFSReader();
        r.registerListener(new MyPOIFSReaderListener(),
                           SummaryInformation.DEFAULT_STREAM_NAME);
        r.read(new FileInputStream(filename));
    }
View Full Code Here

Examples of org.apache.poi.poifs.eventfilesystem.POIFSReader

        poiFs.writeFilesystem(out);
        out.close();
   
        /* Read the POIFS: */
        final PropertySet[] psa = new PropertySet[1];
        final POIFSReader r = new POIFSReader();
        r.registerListener(new POIFSReaderListener()
            {
                public void processPOIFSReaderEvent
                    (final POIFSReaderEvent event)
                {
                    try
                    {
                        psa[0] = PropertySetFactory.create(event.getStream());
                    }
                    catch (Exception ex)
                    {
                        fail(org.apache.poi.hpsf.Util.toString(ex));
                    }
                }
   
            },
            SummaryInformation.DEFAULT_STREAM_NAME);
        r.read(new FileInputStream(filename));
        Assert.assertNotNull(psa[0]);
        Assert.assertTrue(psa[0].isSummaryInformation());

        final Section s = (Section) (psa[0].getSections().get(0));
        Object p1 = s.getProperty(PropertyIDMap.PID_AUTHOR);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.