/** * Read from an InputStream and process the documents we get * * @param stream the InputStream from which to read the data * * @exception IOException on errors reading, or on invalid data */ public void read(final InputStream stream) throws IOException { try (POIFSFileSystem poifs = new POIFSFileSystem(stream)) { read(poifs); } }
/** * Read from a File and process the documents we get * * @param poifsFile the file from which to read the data * * @exception IOException on errors reading, or on invalid data */ public void read(final File poifsFile) throws IOException { try (POIFSFileSystem poifs = new POIFSFileSystem(poifsFile, true)) { read(poifs); } }
/** * read in files * * @param args names of the files * * @exception IOException if the files can't be read or have invalid content */ public static void main(String args[]) throws IOException { if (args.length == 0) { System.err.println("at least one argument required: input filename(s)"); System.exit(1); } // register for all for (String arg : args) { POIFSReader reader = new POIFSReader(); reader.registerListener(POIFSReader::readEntry); System.out.println("reading " + arg); reader.read(new File(arg)); } }
public Void run() throws Exception { poiFSReader.read(is); return null; } });
/** * Read from an InputStream and process the documents we get * * @param stream the InputStream from which to read the data * * @exception IOException on errors reading, or on invalid data */ public void read(final InputStream stream) throws IOException { try (POIFSFileSystem poifs = new POIFSFileSystem(stream)) { read(poifs); } }
/** * Read from a File and process the documents we get * * @param poifsFile the file from which to read the data * * @exception IOException on errors reading, or on invalid data */ public void read(final File poifsFile) throws IOException { try (POIFSFileSystem poifs = new POIFSFileSystem(poifsFile, true)) { read(poifs); } }
POIFSReader r = new POIFSReader(); r.registerListener(new MyPOIFSReaderListener(), "\005SummaryInformation"); r.read(new FileInputStream(filename));
/** * read in files * * @param args names of the files * * @exception IOException if the files can't be read or have invalid content */ public static void main(String args[]) throws IOException { if (args.length == 0) { System.err.println("at least one argument required: input filename(s)"); System.exit(1); } // register for all for (String arg : args) { POIFSReader reader = new POIFSReader(); reader.registerListener(POIFSReader::readEntry); System.out.println("reading " + arg); reader.read(new File(arg)); } }
/** * {@inheritDoc} */ public Reader extractText(InputStream stream, String type, String encoding) throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); MsPowerPointListener listener = new MsPowerPointListener(baos); POIFSReader reader = new POIFSReader(); reader.registerListener(listener); reader.read(stream); return new InputStreamReader( new ByteArrayInputStream(baos.toByteArray())); } catch (RuntimeException e) { logger.warn("Failed to extract PowerPoint text content", e); return new StringReader(""); } finally { stream.close(); } }
public static void parseCompObj(InputStream file) { Collector collector = new Collector(); POIFSReader poifsReader = new POIFSReader(); poifsReader.registerListener(collector, "\001CompObj"); try { poifsReader.read(file); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // collector.classId now contains the result. }
public static void parseCompObj(InputStream file) { Collector collector = new Collector(); POIFSReader poifsReader = new POIFSReader(); poifsReader.registerListener(collector, "\001CompObj"); try { poifsReader.read(file); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // collector.classId now contains the result. }
/** * <p>Runs the example program.</p> * * @param args Command-line arguments. The first command-line argument must * be the name of a POI filesystem to read. * @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(), SummaryInformation.DEFAULT_STREAM_NAME); r.read(new File(filename)); }
/** * read in files * * @param args names of the files * * @exception IOException */ public static void main(String args[]) throws IOException { if (args.length == 0) { System.err .println("at least one argument required: input filename(s)"); System.exit(1); } // register for all for (int j = 0; j < args.length; j++) { POIFSReader reader = new POIFSReader(); POIFSReaderListener listener = new SampleListener(); reader.registerListener(listener); System.out.println("reading " + args[ j ]); FileInputStream istream = new FileInputStream(args[ j ]); reader.read(istream); istream.close(); } }
protected void initializeReader() throws IOException { InputStream in; try { in = blob.getStream(); } catch (RepositoryException e) { throw new IOException(e.getMessage()); } try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); MsPowerPointListener listener = new MsPowerPointListener(baos); POIFSReader reader = new POIFSReader(); reader.registerListener(listener); reader.read(in); delegate = new InputStreamReader( new ByteArrayInputStream(baos.toByteArray())); } finally { in.close(); } } };
/** * <p>Runs the example program.</p> * * @param args Command-line arguments (unused). * @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(); /* Register a listener for *all* documents. */ r.registerListener(new MyPOIFSReaderListener()); r.read(new File(filename)); }
public static MSOfficeMetadata instance( InputStream stream ) throws Exception { POIFSReader r = new POIFSReader(); MSOfficeMetadata MSOfficeMetadataListener = new MSOfficeMetadata(); r.registerListener(MSOfficeMetadataListener, "\005SummaryInformation"); r.read(stream); return MSOfficeMetadataListener; } }
public static MSOfficeMetadata instance( InputStream stream ) throws Exception { POIFSReader r = new POIFSReader(); MSOfficeMetadata MSOfficeMetadataListener = new MSOfficeMetadata(); r.registerListener(MSOfficeMetadataListener, "\005SummaryInformation"); r.read(stream); return MSOfficeMetadataListener; } }
/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(java.io.InputStream, java.lang.String) */ @Override public I_CmsExtractionResult extractText(InputStream in, String encoding) throws Exception { String rawContent = ""; try { POIFSReader reader = new POIFSReader(); reader.registerListener(this); reader.read(in); // extract all information rawContent = removeControlChars(m_buffer.toString()); // free buffer memory m_buffer = new StringBuffer(4096); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } // combine the meta information with the content and create the result return createExtractionResult(rawContent); }
/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(java.io.InputStream, java.lang.String) */ @Override public I_CmsExtractionResult extractText(InputStream in, String encoding) throws Exception { String rawContent = ""; try { // first extract the table content rawContent = extractTableContent(getStreamCopy(in)); rawContent = removeControlChars(rawContent); // now extract the meta information using POI POIFSReader reader = new POIFSReader(); reader.registerListener(this); reader.read(getStreamCopy(in)); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } // combine the meta information with the content and create the result return createExtractionResult(rawContent); }
/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(java.io.InputStream, java.lang.String) */ @Override public I_CmsExtractionResult extractText(InputStream in, String encoding) throws Exception { String rawContent = ""; try { // first extract the text using the text abstraction libary WordExtractor wordExtractor = new WordExtractor(); rawContent = wordExtractor.extractText(getStreamCopy(in)); rawContent = removeControlChars(rawContent); // now extract the meta information using POI POIFSReader reader = new POIFSReader(); reader.registerListener(this); reader.read(getStreamCopy(in)); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } // combine the meta information with the content and create the result return createExtractionResult(rawContent); } }