From b728c6f5df07536be791556dab836a518e2a5624 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 14 May 2003 21:30:29 +0000 Subject: [PATCH] Stream utilities. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1131 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/io/StreamUtil.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 projects/samskivert/src/java/com/samskivert/io/StreamUtil.java diff --git a/projects/samskivert/src/java/com/samskivert/io/StreamUtil.java b/projects/samskivert/src/java/com/samskivert/io/StreamUtil.java new file mode 100644 index 00000000..58d387ec --- /dev/null +++ b/projects/samskivert/src/java/com/samskivert/io/StreamUtil.java @@ -0,0 +1,46 @@ +// +// $Id: StreamUtil.java,v 1.1 2003/05/14 21:30:29 ray Exp $ + +package com.samskivert.io; + +import java.io.InputStream; +import java.io.IOException; +import java.io.OutputStream; + +import com.samskivert.Log; + +/** + * Convenience methods for streams. + */ +public class StreamUtil +{ + /** + * Convenient close for a stream. Use in a finally clause and love life. + */ + public static void close (InputStream in) + { + if (in != null) { + try { + in.close(); + } catch (IOException ioe) { + Log.warning("Error closing input stream [stream=" + in + + ", cause=" + ioe + "]."); + } + } + } + + /** + * Convenient close for a stream. Use in a finally clause and love life. + */ + public static void close (OutputStream out) + { + if (out != null) { + try { + out.close(); + } catch (IOException ioe) { + Log.warning("Error closing output stream [stream=" + out + + ", cause=" + ioe + "]."); + } + } + } +}