Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.io
Class FileManager

    java.lang.Object
      de.jstacs.io.FileManager

    public class FileManager

extends Object

This class is for handling `File`s. The most important methods of this class are for writing a `StringBuffer` to or reading it from a `File`. This is useful for all objects that implement `Storable` and should be saved in or loaded from a `File`.

Author:
  Jens Keilwagen
See Also:
  `Storable`, `File`

Method Summary
`static void` | `copy(String from, String to)` This method copies a `File` in a faster manner.
`static void` | `copy(String from, String to, byte[] buffer)` This method copies a `File` in a faster manner using a specified buffer.
`static int` | `copyDiff(File source, File target, Date date, boolean recursive, FileFilter filter)` This method copies all `File`s and directories, if selected, from a `source` `File`, i.e. directory, to a `target` `File`, i.e. directory, that have been modified after a predefined `date`.
`static StringBuffer` | `readFile(File file)` This method reads a `StringBuffer` from a given `File`.
`static void` | `writeFile(File outputFile, StringBuffer buffer)` This method saves a `StringBuffer` to a given `File`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### copyDiff

    public static int copyDiff(File source,
                               File target,
                               Date date,
                               boolean recursive,
                               FileFilter filter)
                        throws IllegalArgumentException,
                               IOException

  This method copies all `File`s and directories, if selected, from a `source` `File`, i.e. directory, to a `target` `File`, i.e. directory, that have been modified after a predefined `date`.

  Parameters:
    `source` - the source directory denoted as `File`
    `target` - the target directory denoted as `File`
    `date` - the `Date`
    `recursive` - indicates if this method should be used recursively in the subdirectories
    `filter` - a `FileFilter` for the `File`s that enables the user to copy only specific `File`s
  Returns:
    the number of copied `File`s
  Throws:
    `IllegalArgumentException` - if `source` and `target` are not directories
    `IOException` - if something went wrong while copying the `File`s and directories
  See Also:
    `File`, `Date`, `FileFilter`

### copy

    public static void copy(String from,
                            String to)
                     throws IOException

  This method copies a `File` in a faster manner.

  Parameters:
    `from` - the `File` name of the original file
    `to` - the `File` name of the copied file
  Throws:
    `IOException` - if something went wrong
  See Also:
    `copy(String, String, byte[])`

### copy

    public static void copy(String from,
                            String to,
                            byte[] buffer)
                     throws IOException

  This method copies a `File` in a faster manner using a specified buffer.

  Parameters:
    `from` - the `File` name of the original file
    `to` - the `File` name of the copied file
    `buffer` - an array for reading the content of the original `File`, the size of the array determines how many `byte`s are read at once
  Throws:
    `IOException` - if something went wrong

### readFile

    public static StringBuffer readFile(File file)
                                 throws IOException

  This method reads a `StringBuffer` from a given `File`.

  Parameters:
    `file` - the `File` to be read
  Returns:
    a `StringBuffer` with the content of the `File`
  Throws:
    `IOException` - if something went wrong with the `File`
  See Also:
    `writeFile(File, StringBuffer)`

### writeFile

    public static void writeFile(File outputFile,
                                 StringBuffer buffer)
                          throws IOException

  This method saves a `StringBuffer` to a given `File`.

  Parameters:
    `outputFile` - the `File` into which the output should be written
    `buffer` - the buffer to be written in the `File`
  Throws:
    `IOException` - if something went wrong with the `File`
  See Also:
    `readFile(File)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD