org.apache.tuscany.sca.contribution.service.util
Class IOHelper

java.lang.Object
  extended by org.apache.tuscany.sca.contribution.service.util.IOHelper

public class IOHelper
extends java.lang.Object


Nested Class Summary
static class IOHelper.SafeURLInputStream
          This class is a workaround for URL stream issue as illustrated below.
 
Constructor Summary
IOHelper()
           
 
Method Summary
static void closeQuietly(java.io.InputStream input)
          Unconditionally close an InputStream.
static void closeQuietly(java.io.OutputStream output)
          Unconditionally close an OutputStream.
static int copy(java.io.InputStream input, java.io.OutputStream output)
          Copy bytes from an InputStream to an OutputStream.
static java.io.InputStream getInputStream(java.net.URL url)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOHelper

public IOHelper()
Method Detail

closeQuietly

public static void closeQuietly(java.io.InputStream input)
Unconditionally close an InputStream.

Equivalent to IOHelper.SafeURLInputStream.close(), except any exceptions will be ignored. This is typically used in finally blocks.

Parameters:
input - the InputStream to close, may be null or already closed

closeQuietly

public static void closeQuietly(java.io.OutputStream output)
Unconditionally close an OutputStream.

Equivalent to OutputStream.close(), except any exceptions will be ignored. This is typically used in finally blocks.

Parameters:
output - the OutputStream to close, may be null or already closed

copy

public static int copy(java.io.InputStream input,
                       java.io.OutputStream output)
                throws java.io.IOException
Copy bytes from an InputStream to an OutputStream.

This method buffers the input internally, so there is no need to use a BufferedInputStream.

Parameters:
input - the InputStream to read from
output - the OutputStream to write to
Returns:
the number of bytes copied
Throws:
java.lang.NullPointerException - if the input or output is null
java.io.IOException - if an I/O error occurs
Since:
Commons IO 1.1

getInputStream

public static java.io.InputStream getInputStream(java.net.URL url)
                                          throws java.io.IOException
Throws:
java.io.IOException