Package org.apache.poi.poifs.filesystem

Examples of org.apache.poi.poifs.filesystem.DirectoryEntry


        InputStream is = new FileInputStream(poiFilesystem);
        POIFSFileSystem poifs = new POIFSFileSystem(is);
        is.close();

        /* Read the summary information. */
        DirectoryEntry dir = poifs.getRoot();
        SummaryInformation si;
        try
        {
            DocumentEntry siEntry = (DocumentEntry)
                dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
            DocumentInputStream dis = new DocumentInputStream(siEntry);
            PropertySet ps = new PropertySet(dis);
            dis.close();
            si = new SummaryInformation(ps);
        }
        catch (FileNotFoundException ex)
        {
            /* There is no summary information yet. We have to create a new
             * one. */
            si = PropertySetFactory.newSummaryInformation();
        }

        /* Change the author to "Rainer Klute". Any former author value will
         * be lost. If there has been no author yet, it will be created. */
        si.setAuthor("Rainer Klute");
        System.out.println("Author changed to " + si.getAuthor() + ".");


        /* Handling the document summary information is analogous to handling
         * the summary information. An additional feature, however, are the
         * custom properties. */

        /* Read the document summary information. */
        DocumentSummaryInformation dsi;
        try
        {
            DocumentEntry dsiEntry = (DocumentEntry)
                dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            DocumentInputStream dis = new DocumentInputStream(dsiEntry);
            PropertySet ps = new PropertySet(dis);
            dis.close();
            dsi = new DocumentSummaryInformation(ps);
        }
View Full Code Here


   * @throws IOException
   *
   */
  public void reparseFileSystem() throws IOException {
    // first clear this object of all chunks
    DirectoryEntry root = this.fs.getRoot();
    Iterator iter = root.getEntries();
   
    this.directoryMap = this.processPOIIterator(iter);
  }
View Full Code Here

        }
      }
    } else if(ext instanceof WordExtractor) {
      // These are in ObjectPool -> _... under the root
      try {
        DirectoryEntry op = (DirectoryEntry)
          fs.getRoot().getEntry("ObjectPool");
        Iterator it = op.getEntries();
        while(it.hasNext()) {
          Entry entry = (Entry)it.next();
          if(entry.getName().startsWith("_")) {
            dirs.add(entry);
          }
View Full Code Here

   */
  protected void copyNodes(POIFSFileSystem source, POIFSFileSystem target,
                            List excepts) throws IOException {
    //System.err.println("CopyNodes called");

    DirectoryEntry root = source.getRoot();
    DirectoryEntry newRoot = target.getRoot();

    Iterator entries = root.getEntries();

    while (entries.hasNext()) {
      Entry entry = (Entry)entries.next();
View Full Code Here

   */
  private void copyNodeRecursively(Entry entry, DirectoryEntry target)
  throws IOException {
    //System.err.println("copyNodeRecursively called with "+entry.getName()+
    //                   ","+target.getName());
    DirectoryEntry newTarget = null;
    if (entry.isDirectoryEntry()) {
      newTarget = target.createDirectory(entry.getName());
      Iterator entries = ((DirectoryEntry)entry).getEntries();

      while (entries.hasNext()) {
View Full Code Here

    System.out.println();
  }

  public void testSingleEmptyDocument() throws IOException {
    POIFSFileSystem fs = new POIFSFileSystem();
    DirectoryEntry dir = fs.getRoot();
    dir.createDocument("Foo", new ByteArrayInputStream(new byte[] { }));
   
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    fs.writeFilesystem(out);
    new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
  }
View Full Code Here

    new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
  }

  public void testSingleEmptyDocumentEvent() throws IOException {
    POIFSFileSystem fs = new POIFSFileSystem();
    DirectoryEntry dir = fs.getRoot();
    dir.createDocument("Foo", 0, new POIFSWriterListener() {
      public void processPOIFSWriterEvent(POIFSWriterEvent event) {
        System.out.println("written");
      }
    });
   
View Full Code Here

    new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
  }

  public void testEmptyDocumentWithFriend() throws IOException {
    POIFSFileSystem fs = new POIFSFileSystem();
    DirectoryEntry dir = fs.getRoot();
    dir.createDocument("Bar", new ByteArrayInputStream(new byte[] { 0 }));
    dir.createDocument("Foo", new ByteArrayInputStream(new byte[] { }));
   
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    fs.writeFilesystem(out);
    new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
  }
View Full Code Here

    new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
  }

  public void testEmptyDocumentEventWithFriend() throws IOException {
    POIFSFileSystem fs = new POIFSFileSystem();
    DirectoryEntry dir = fs.getRoot();
    dir.createDocument("Bar", 1, new POIFSWriterListener() {
      public void processPOIFSWriterEvent(POIFSWriterEvent event) {
        try {
          event.getStream().write(0);
        } catch (IOException exception) {
          throw new RuntimeException("exception on write: " + exception);
        }
      }
    });
    dir.createDocument("Foo", 0, new POIFSWriterListener() {
      public void processPOIFSWriterEvent(POIFSWriterEvent event) {
      }
    });
   
    ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

   */
  protected void copyNodes(POIFSFileSystem source, POIFSFileSystem target,
                            List excepts) throws IOException {
    //System.err.println("CopyNodes called");

    DirectoryEntry root = source.getRoot();
    DirectoryEntry newRoot = target.getRoot();

    Iterator entries = root.getEntries();

    while (entries.hasNext()) {
      Entry entry = (Entry)entries.next();
View Full Code Here

TOP

Related Classes of org.apache.poi.poifs.filesystem.DirectoryEntry

Copyright © 2018 www.massapicom. 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.