Package org.apache.poi.poifs.filesystem

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


                if (inputStream instanceof TikaInputStream) {
                    TikaInputStream tin = (TikaInputStream) inputStream;

                    if (tin.getOpenContainer() != null && tin.getOpenContainer() instanceof DirectoryEntry) {
                        POIFSFileSystem fs = new POIFSFileSystem();
                        copy((DirectoryEntry) tin.getOpenContainer(), fs.getRoot());
                        fs.writeFilesystem(os);
                    } else {
                        IOUtils.copy(inputStream, os);
                    }
                } else {
                    IOUtils.copy(inputStream, os);
View Full Code Here


          logger.warn("Unexpected MimeTypeException", e);
        }
      }

      if ("application/vnd.openxmlformats-officedocument.oleObject".equals(contentType)) {
        POIFSFileSystem poifs = new POIFSFileSystem(new ByteArrayInputStream(data));
        OfficeParser.POIFSDocumentType type = OfficeParser.POIFSDocumentType.detectType(poifs);

        if (type == OfficeParser.POIFSDocumentType.OLE10_NATIVE) {
          try {
            Ole10Native ole = Ole10Native.createFromEmbeddedOleObject(poifs);
            if (ole.getDataSize()>0) {
              String label = ole.getLabel();

              if (label.startsWith("ole-")) {
                label = Integer.toString(count.intValue()) + '-' + label;
              }

              name = label;

              data = ole.getDataBuffer();
            }
          } catch (Ole10NativeException ex) {
            logger.warn("Skipping invalid part", ex);
          }
        } else {
          name += '.' + type.getExtension();
        }
      }

      final String finalName = name;

      if (data.length > 0) {
        zout.put(finalName, data);

        count.increment();
      } else {
        if (inputStream instanceof TikaInputStream) {
          TikaInputStream tin = (TikaInputStreaminputStream;

          if (tin.getOpenContainer()!=null && tin.getOpenContainer() instanceof DirectoryEntry) {
            POIFSFileSystem fs = new POIFSFileSystem();
            copy((DirectoryEntry) tin.getOpenContainer(), fs.getRoot());
            ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
            fs.writeFilesystem(bos2);
            bos2.close();

            zout.put(finalName, bos2.toByteArray());
          }
        }
View Full Code Here

   *  Constructor
   */

  public POIFSSerializer() {
    super();
    _filesystem = new POIFSFileSystem();
  }
View Full Code Here

    public void run()
    {
        try
        {
            POIFSFileSystem fs      =
                new POIFSFileSystem(new FileInputStream(filename));
            InputStream     stream  =
                fs.createDocumentInputStream("Workbook");
            Record[]        records = createRecords(stream, dump);
        }
        catch (Exception e)
        {
            e.printStackTrace();
View Full Code Here

            {
                viewer.setDump(true);
            }
            if ((args.length > 1) && args[ 1 ].equals("bfd"))
            {
                POIFSFileSystem fs     =
                    new POIFSFileSystem(new FileInputStream(args[ 0 ]));
                InputStream     stream =
                    fs.createDocumentInputStream("Workbook");
                int             size   = stream.available();
                byte[]          data   = new byte[ size ];

                stream.read(data);
                HexDump.dump(data, 0, System.out, 0);
View Full Code Here

     */

    public HSSFWorkbook(InputStream s)
            throws IOException
    {
        this((new POIFSFileSystem(s)));
    }
View Full Code Here

    public void write(OutputStream stream)
            throws IOException
    {
        byte[] bytes = getBytes();
        POIFSFileSystem fs = new POIFSFileSystem();

        fs.createDocument(new ByteArrayInputStream(bytes), "Workbook");
        fs.writeFilesystem(stream);
    }
View Full Code Here

    public void run()
    {
        try
        {
            POIFSFileSystem fs      =
                new POIFSFileSystem(new FileInputStream(filename));
            InputStream     stream  =
                fs.createDocumentInputStream("Workbook");
            Record[]        records = createRecords(stream, dump);
        }
        catch (Exception e)
        {
            e.printStackTrace();
View Full Code Here

            {
                viewer.setDump(true);
            }
            if ((args.length > 1) && args[ 1 ].equals("bfd"))
            {
                POIFSFileSystem fs     =
                    new POIFSFileSystem(new FileInputStream(args[ 0 ]));
                InputStream     stream =
                    fs.createDocumentInputStream("Workbook");
                int             size   = stream.available();
                byte[]          data   = new byte[ size ];

                stream.read(data);
                HexDump.dump(data, 0, System.out, 0);
View Full Code Here

     */

    public HSSFWorkbook(InputStream s)
        throws IOException
    {
        this((new POIFSFileSystem(s)));
    }
View Full Code Here

TOP

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

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.