net.sf.jnati
Class FileUtils

java.lang.Object
  extended by net.sf.jnati.FileUtils

public class FileUtils
extends Object

Author:
Sam Adams

Constructor Summary
FileUtils()
           
 
Method Summary
static void copyStreamToStream(InputStream in, OutputStream out)
          Copys the entire contents of an InputStream to an OutputStream.
static boolean delTree(File dir)
          Deletes a directory and its contents.
static File getTmpDir()
          Creates a temporary directory in the default system location.
static File getTmpDir(File root)
          Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.
static File getTmpDir(String path)
          Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.
static byte[] readBytes(InputStream in)
          Reads the entire contents of an InputStream into an array of bytes.
static String readString(Reader in)
          Reads entire contents of reader into a string.
static void writeStreamToFile(InputStream in, File file)
          Writes the contents of an input stream to a file.
static void writeString(File file, String string)
          Writes the contents of a string to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
Method Detail

getTmpDir

public static File getTmpDir()
                      throws IOException
Creates a temporary directory in the default system location.

Returns:
Throws:
IOException

getTmpDir

public static File getTmpDir(String path)
                      throws IOException
Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.

Parameters:
path -
Returns:
Throws:
IOException

getTmpDir

public static File getTmpDir(File root)
                      throws IOException
Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.

Parameters:
path -
Returns:
Throws:
IOException

delTree

public static boolean delTree(File dir)
Deletes a directory and its contents.

Parameters:
dir -
Returns:
True on success, false on failure.

writeStreamToFile

public static void writeStreamToFile(InputStream in,
                                     File file)
                              throws IOException
Writes the contents of an input stream to a file. If the file already exists, it will be overwritten.

Parameters:
in - Input stream providing file contents
file - File to write to
Throws:
IOException

copyStreamToStream

public static void copyStreamToStream(InputStream in,
                                      OutputStream out)
                               throws IOException
Copys the entire contents of an InputStream to an OutputStream.

Parameters:
in -
out -
Throws:
IOException

readBytes

public static byte[] readBytes(InputStream in)
                        throws IOException
Reads the entire contents of an InputStream into an array of bytes.

Parameters:
in -
Returns:
Throws:
IOException

readString

public static String readString(Reader in)
                         throws IOException
Reads entire contents of reader into a string.

Parameters:
in -
Returns:
Throws:
IOException

writeString

public static void writeString(File file,
                               String string)
                        throws IOException
Writes the contents of a string to a file. If the file already exists it is over-written.

Parameters:
file -
string -
Throws:
IOException


Copyright © 2007-2011 Sam Adams. All Rights Reserved.