public void close() throws IOException { fs.close(); fs = null; }
@Override public void close() throws IOException { fs.close(); super.close(); } };
private static void viewFile(String filename, boolean printName) { if (printName) { StringBuffer flowerbox = new StringBuffer(); flowerbox.append("."); for (int j = 0; j < filename.length(); j++) { flowerbox.append("-"); } flowerbox.append("."); System.out.println(flowerbox); System.out.println("|" + filename + "|"); System.out.println(flowerbox); } try { POIFSFileSystem fs = new POIFSFileSystem(new File(filename)); List<String> strings = POIFSViewEngine.inspectViewable(fs, true, 0, " "); for (String s : strings) { System.out.print(s); } fs.close(); } catch (IOException e) { System.out.println(e.getMessage()); } } }
public static void viewFileOld(final String filename, boolean withSizes) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename)); displayDirectory(fs.getRoot(), "", withSizes); fs.close(); }
public static void viewFile(final String filename, boolean withSizes) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new File(filename)); displayDirectory(fs.getRoot(), "", withSizes); fs.close(); }
public static void main( String[] args ) throws IOException { OutputStreamWriter osw = new OutputStreamWriter(System.out, Charset.defaultCharset()); PrintWriter pw = new PrintWriter(osw); POIFSFileSystem fs = new POIFSFileSystem(new File(args[0])); HSSFWorkbook wb = new HSSFWorkbook(fs); try { pw.println( "Drawing group:" ); wb.dumpDrawingGroupRecords(true); int i = 1; for (Sheet sheet : wb) { pw.println( "Sheet " + i + "(" + sheet.getSheetName() + "):" ); ((HSSFSheet) sheet).dumpDrawingRecords(true, pw); } } finally { wb.close(); fs.close(); } } }
/** * Closes the underlying {@link POIFSFileSystem} from which * the document was read, if any. Has no effect on documents * opened from an InputStream, or newly created ones.<p> * * Once {@code close()} has been called, no further operations * should be called on the document. */ @Override public void close() throws IOException { if (directory != null) { if (directory.getNFileSystem() != null) { directory.getNFileSystem().close(); clearDirectory(); } } }
/** * Method run * * @throws IOException if the file contained errors */ public void run() throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new File(file), true); try { InputStream is = BiffViewer.getPOIFSInputStream(fs); try { List<Record> records = RecordFactory.createRecords(is); for (Record record : records) { if (record.getSid() == FormulaRecord.sid) { if (list) { listFormula((FormulaRecord) record); } else { parseFormulaRecord((FormulaRecord) record); } } } } finally { is.close(); } } finally { fs.close(); } }
private void open(InputStream biffStream) throws IOException { BufferedInputStream bis = (biffStream instanceof BufferedInputStream) ? (BufferedInputStream)biffStream : new BufferedInputStream(biffStream, 8); if (FileMagic.valueOf(bis) == FileMagic.OLE2) { POIFSFileSystem poifs = new POIFSFileSystem(bis); try { open(poifs); toClose = poifs; // Fixed by GR, we should not close it here } finally { if (toClose == null) { poifs.close(); } } } else { ris = new RecordInputStream(bis); toClose = bis; prepare(); } }
root.getFileSystem().close();
root.getFileSystem().close();
private static POITextExtractor createEncryptedOOXMLExtractor(POIFSFileSystem fs) throws IOException { String pass = Biff8EncryptionKey.getCurrentUserPassword(); if (pass == null) { pass = Decryptor.DEFAULT_PASSWORD; } EncryptionInfo ei = new EncryptionInfo(fs); Decryptor dec = ei.getDecryptor(); InputStream is = null; try { if (!dec.verifyPassword(pass)) { throw new EncryptedDocumentException("Invalid password specified - use Biff8EncryptionKey.setCurrentUserPassword() before calling extractor"); } is = dec.getDataStream(fs); return createExtractor(OPCPackage.open(is)); } catch (IOException e) { throw e; } catch (Exception e) { throw new EncryptedDocumentException(e); } finally { IOUtils.closeQuietly(is); // also close the NPOIFSFileSystem here as we read all the data // while decrypting fs.close(); } } }
public void close() throws IOException { fs.close(); fs = null; }
private void handleCompoundContent(OleBlob.CompoundContent cc, XHTMLContentHandler xhtml) throws IOException, SAXException, TikaException { InputStream is = null; POIFSFileSystem fileSystem = null; try { try { is = cc.getStream(); } catch (IOException e) { EmbeddedDocumentUtil.recordEmbeddedStreamException(e, parentMetadata); return; } try { fileSystem = new POIFSFileSystem(is); } catch (Exception e) { EmbeddedDocumentUtil.recordEmbeddedStreamException(e, parentMetadata); return; } handleEmbeddedOfficeDoc(fileSystem.getRoot(), xhtml); } finally { if (fileSystem != null) { try { fileSystem.close(); } catch (IOException e) { //swallow } } if (is != null) { IOUtils.closeQuietly(is); } } }
} finally { if (poifs != null) { poifs.close();
public static void viewFile(final String filename, boolean withSizes) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new File(filename)); displayDirectory(fs.getRoot(), "", withSizes); fs.close(); }
public static void viewFileOld(final String filename, boolean withSizes) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename)); displayDirectory(fs.getRoot(), "", withSizes); fs.close(); }
public static void main(String[] args) throws Exception { for(String file : args) { POIFSFileSystem fs = new POIFSFileSystem(new File(file), true); HSMFDump dump = new HSMFDump(fs); dump.dump(); fs.close(); } } }
public PPTXMLDump(File ppt) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(ppt, true); try { docstream = readEntry(fs, HSLFSlideShow.POWERPOINT_DOCUMENT); pictstream = readEntry(fs, PICTURES_ENTRY); } finally { fs.close(); } }
} finally { if (fs != null) { fs.close();