org.apache.ws.util
Class IoUtils

java.lang.Object
  extended byorg.apache.ws.util.IoUtils

public abstract class IoUtils
extends java.lang.Object

LOG-DONE Generic I/O utility methods.

Author:
Ian P. Springer, Sal Campana

Constructor Summary
IoUtils()
           
 
Method Summary
static void copy(java.io.File sourceFile, java.io.File targetFile)
          Copies one file to another.
static void copy(java.io.InputStream in, java.io.File targetFile)
          Copies an input stream to a file.
static void copy(java.io.InputStream in, java.io.OutputStream out)
          Copies an input stream to an output stream.
static boolean deleteDir(java.io.File dir)
          Deletes all files and subdirectories under dir.
static java.io.ByteArrayInputStream toByteArrayInputStream(java.io.ByteArrayOutputStream out)
          Converts a ByteArrayOutputStream into a ByteArrayInputStream.
static java.io.InputStream toInputStream(java.lang.String str)
          Convert the specified string to an input stream.
static java.lang.String toString(java.io.InputStream in)
          TODO
static java.lang.String toString(java.io.InputStream in, java.lang.String encoding)
          TODO
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IoUtils

public IoUtils()
Method Detail

copy

public static void copy(java.io.InputStream in,
                        java.io.OutputStream out)
                 throws java.io.IOException
Copies an input stream to an output stream.

Parameters:
in - an input stream; must not be null
out - an output stream; must not be null
Throws:
java.io.IOException - if the copy fails

copy

public static void copy(java.io.InputStream in,
                        java.io.File targetFile)
                 throws java.io.IOException
Copies an input stream to a file.

Parameters:
in - an input stream to copy from
targetFile - the file to copy to; if the file already exists, it will be overwritten
Throws:
java.io.IOException - if the copy fails

copy

public static void copy(java.io.File sourceFile,
                        java.io.File targetFile)
                 throws java.io.IOException
Copies one file to another.

Parameters:
sourceFile - an existing file to copy from
targetFile - the file to copy to; if the file already exists, it will be overwritten
Throws:
java.io.IOException - if the copy fails

deleteDir

public static boolean deleteDir(java.io.File dir)
Deletes all files and subdirectories under dir. Returns true if all deletions were successful. If a deletion fails, the method stops attempting to delete and returns false.


toByteArrayInputStream

public static java.io.ByteArrayInputStream toByteArrayInputStream(java.io.ByteArrayOutputStream out)
Converts a ByteArrayOutputStream into a ByteArrayInputStream.

Parameters:
out -
Returns:
ByteArrayInputStream

toInputStream

public static java.io.InputStream toInputStream(java.lang.String str)
Convert the specified string to an input stream.

Parameters:
str - a string
Returns:
an input stream

toString

public static java.lang.String toString(java.io.InputStream in)
                                 throws java.io.IOException
TODO

Parameters:
in -
Returns:
Throws:
java.io.IOException

toString

public static java.lang.String toString(java.io.InputStream in,
                                        java.lang.String encoding)
                                 throws java.io.IOException
TODO

Parameters:
in -
encoding -
Returns:
Throws:
java.io.IOException


Copyright © 2004-2005 Apache Software Foundation. All Rights Reserved.