org.ujac.util.io
Class FileUtils

java.lang.Object
  extended by org.ujac.util.io.FileUtils

public class FileUtils
extends Object

Name: FileUtils
Description: Class providing common utility methods for file handling.

Author:
lauerc

Field Summary
static int IO_BUFFER_SIZE
          The I/O buffer size.
 
Constructor Summary
FileUtils()
           
 
Method Summary
static int copyFile(File src, File dst)
          Copies the contents of the given file src into the given file dst.
static int copyFromBytes(byte[] bytes, File dest)
          Copies the contents of the given byte array bytes into the given output file file.
static int copyFromReader(Reader reader, File dest)
          Copies the contents of the given reader reader into the given output file file.
static int copyFromStream(InputStream is, File dest)
          Copies the contents of the given input stream is into the given output file file.
static int copyStreamToStream(InputStream is, OutputStream os, boolean closeOs)
          Copies the contents of the given input stream is into the given output file file.
static int copyToStream(File src, OutputStream os)
          Copies the contents of the given file src into the given output stream os.
static byte[] loadFile(File file)
          Loads the contents of the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IO_BUFFER_SIZE

public static final int IO_BUFFER_SIZE
The I/O buffer size.

See Also:
Constant Field Values
Constructor Detail

FileUtils

public FileUtils()
Method Detail

loadFile

public static final byte[] loadFile(File file)
                             throws IOException
Loads the contents of the given file.

Parameters:
file - The file to load.
Returns:
The loaded data from the file.
Throws:
IOException - In case the loading of the file failed.

copyFile

public static final int copyFile(File src,
                                 File dst)
                          throws IOException
Copies the contents of the given file src into the given file dst.

Parameters:
src - The file to copy from.
dst - The file to copy to.
Returns:
The number of bytes copied.
Throws:
IOException - In case the loading of the file failed.

copyToStream

public static final int copyToStream(File src,
                                     OutputStream os)
                              throws IOException
Copies the contents of the given file src into the given output stream os.

Parameters:
src - The file to copy from.
os - The stream to write to.
Returns:
The number of bytes copied.
Throws:
IOException - In case the loading of the file failed.

copyFromBytes

public static final int copyFromBytes(byte[] bytes,
                                      File dest)
                               throws IOException
Copies the contents of the given byte array bytes into the given output file file.

Parameters:
bytes - The bytes to copy.
dest - The file to write to.
Returns:
The number of bytes copied.
Throws:
IOException - In case the loading of the file failed.

copyFromStream

public static final int copyFromStream(InputStream is,
                                       File dest)
                                throws IOException
Copies the contents of the given input stream is into the given output file file.

Parameters:
is - The input stream to copy from.
dest - The file to write to.
Returns:
The number of bytes copied.
Throws:
IOException - In case the loading of the file failed.

copyStreamToStream

public static final int copyStreamToStream(InputStream is,
                                           OutputStream os,
                                           boolean closeOs)
                                    throws IOException
Copies the contents of the given input stream is into the given output file file.

Parameters:
is - The input stream to copy from.
os - The output stream to write to.
closeOs - Tells, whether or not to close the output stream, false keeps it open.
Returns:
The number of bytes copied.
Throws:
IOException - In case the loading of the file failed.

copyFromReader

public static final int copyFromReader(Reader reader,
                                       File dest)
                                throws IOException
Copies the contents of the given reader reader into the given output file file.

Parameters:
reader - The reader to copy from.
dest - The file to write to.
Returns:
The number of bytes copied.
Throws:
IOException - In case the loading of the file failed.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.