/** * Flushes and closes the specified stream. * * @param pStream The stream to close. */ public static void FlushCloseStream(Stream pStream) { if (pStream != null) { try { pStream.Flush(); StreamUtils.CloseStream(pStream); } catch (IOException e) { e.PrintStackTrace(); } } }
/** * Flushes and closes the specified stream. * * @param pWriter The Writer to close. */ public static void FlushCloseWriter(Stream pWriter) { if (pWriter != null) { try { pWriter.Flush(); StreamUtils.CloseStream(pWriter); } catch (IOException e) { e.PrintStackTrace(); } } }
//public static bool copyAndClose(InputStream input, OutputStream output) public static bool copyAndClose(System.IO.Stream input, System.IO.Stream output) { try { StreamUtils.Copy(input, output, -1); return(true); } catch (IOException e) { return(false); } finally { StreamUtils.CloseStream(input); StreamUtils.CloseStream(output); } }