XDC - v. 0.6.1

net.sf.xdc.util
Class IOUtils

java.lang.Object
  extended bynet.sf.xdc.util.IOUtils

public class IOUtils
extends java.lang.Object

This utility class contains a number of useful static methods related to Stream manipulation.

Since:
0.5
Version:
0.5
Author:
Jens Voß

Method Summary
static void copy(java.io.InputStream input, java.io.OutputStream output)
          Reads byte data in chunks of a specified size from one stream and writes it into another stream.
static void copy(java.io.Reader input, java.io.Writer output)
          Reads character data in chunks of a specified size from a Reader and writes it into a Writer.
static void copyTree(java.io.File srcDir, java.io.File targetDir)
          This method is used to recursively copy the contents of one complete directory tree from one location in the file system to another.
static java.io.Reader getReader(java.io.File file, java.nio.charset.Charset charset)
          This method constructs a Reader object of a File for a given Charset.
static java.io.Reader getReader(java.lang.String filename, java.nio.charset.Charset charset)
          This method constructs a Reader object of a File for a given Charset.
static java.io.Writer getWriter(java.io.File file, java.nio.charset.Charset charset)
          This method constructs a Writer object of a File for a given Charset.
static java.io.Writer getWriter(java.lang.String filename, java.nio.charset.Charset charset)
          This method constructs a Writer object of a File for a given Charset.
static boolean isDefaultExclude(java.lang.String filename)
          This method is used to determine whether a path constituent should be excluded from processing because it is most likely a directory or file containing version control information.
static boolean makeEmpty(java.io.File directory)
          This method is used to completely delete all contents of a directory including all files and (recursively) subdirectories, but not the (specified) directory itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copy

public static void copy(java.io.InputStream input,
                        java.io.OutputStream output)
                 throws java.io.IOException
Reads byte data in chunks of a specified size from one stream and writes it into another stream.

Parameters:
input - The InputStream from which to read the data
output - The OutputStream to which to write the data
Throws:
java.io.IOException

copy

public static void copy(java.io.Reader input,
                        java.io.Writer output)
                 throws java.io.IOException
Reads character data in chunks of a specified size from a Reader and writes it into a Writer.

Parameters:
input - The Reader from which to read the data
output - The Writer to which to write the data
Throws:
java.io.IOException

makeEmpty

public static boolean makeEmpty(java.io.File directory)
This method is used to completely delete all contents of a directory including all files and (recursively) subdirectories, but not the (specified) directory itself.

Parameters:
directory - The directory whose contents are to be deleted
Returns:
true if the directory contains no more files after this operation; false otherwise (i.e. if some file could not be deleted for some reason)

isDefaultExclude

public static boolean isDefaultExclude(java.lang.String filename)
This method is used to determine whether a path constituent should be excluded from processing because it is most likely a directory or file containing version control information.
Excluded filename patterns are:

Parameters:
filename - The name of the path constituent (directory or file) for which a check is performed
Returns:
true if the filename matches one of the above patterns; false otherwise

copyTree

public static void copyTree(java.io.File srcDir,
                            java.io.File targetDir)
                     throws java.io.IOException
This method is used to recursively copy the contents of one complete directory tree from one location in the file system to another.

Parameters:
srcDir - The source directory whose contents are to be copied
targetDir - The target directory (to which the contents of the source directory are copied)
Throws:
java.io.IOException

getReader

public static java.io.Reader getReader(java.io.File file,
                                       java.nio.charset.Charset charset)
                                throws java.io.FileNotFoundException
This method constructs a Reader object of a File for a given Charset.

Parameters:
file - The file for which the Reader is to be constructed
charset - The Charset of the Reader to be constructed
Returns:
A Reader object for the specified File with the specified Charset
Throws:
java.io.FileNotFoundException

getReader

public static java.io.Reader getReader(java.lang.String filename,
                                       java.nio.charset.Charset charset)
                                throws java.io.FileNotFoundException
This method constructs a Reader object of a File for a given Charset.

Parameters:
filename - The name of the file for which the Reader is to be constructed
charset - The Charset of the Reader to be constructed
Returns:
A Reader object for the specified File with the specified Charset
Throws:
java.io.FileNotFoundException

getWriter

public static java.io.Writer getWriter(java.io.File file,
                                       java.nio.charset.Charset charset)
                                throws java.io.IOException
This method constructs a Writer object of a File for a given Charset.

Parameters:
file - The file for which the Writer is to be constructed
charset - The Charset of the Writer to be constructed
Returns:
A Writer object for the specified File with the specified Charset
Throws:
java.io.FileNotFoundException
java.io.IOException

getWriter

public static java.io.Writer getWriter(java.lang.String filename,
                                       java.nio.charset.Charset charset)
                                throws java.io.IOException
This method constructs a Writer object of a File for a given Charset.

Parameters:
filename - The name of the file for which the Writer is to be constructed
charset - The Charset of the Writer to be constructed
Returns:
A Writer object for the specified File with the specified Charset
Throws:
java.io.FileNotFoundException
java.io.IOException

XDC - v. 0.6.1