/** * Write a POI Document ({@link org.apache.poi.ss.usermodel.Workbook}, {@link org.apache.poi.sl.usermodel.SlideShow}, etc) to an output stream and close the output stream. * This will attempt to close the output stream at the end even if there was a problem writing the document to the stream. * This will also attempt to close the document, even if an error occurred while writing the document or closing the output stream. * * If you are using Java 7 or higher, you may prefer to use a try-with-resources statement instead. * This function exists for Java 6 code. * * @param doc a writeable and closeable document to write to the output stream, then close * @param out the output stream that the document is written to * @throws IOException thrown on errors writing to the stream * * @deprecated since 4.0, use try-with-resources, will be removed in 4.2 */ @Deprecated @Removal(version="4.2") public static void writeAndClose(POIDocument doc, OutputStream out) throws IOException { try { write(doc, out); } finally { closeQuietly(doc); } }
/** * Write a POI Document ({@link org.apache.poi.ss.usermodel.Workbook}, {@link org.apache.poi.sl.usermodel.SlideShow}, etc) to an output stream and close the output stream. * This will attempt to close the output stream at the end even if there was a problem writing the document to the stream. * This will also attempt to close the document, even if an error occurred while writing the document or closing the output stream. * * If you are using Java 7 or higher, you may prefer to use a try-with-resources statement instead. * This function exists for Java 6 code. * * @param doc a writeable and closeable document to write to the output stream, then close * @param out the output stream that the document is written to * @throws IOException thrown on errors writing to the stream * * @deprecated since 4.0, use try-with-resources, will be removed in 4.2 */ @Deprecated @Removal(version="4.2") public static void writeAndClose(POIDocument doc, OutputStream out) throws IOException { try { write(doc, out); } finally { closeQuietly(doc); } }