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

## things.common.tools
Class FileTools

    java.lang.Object
      things.common.tools.FileTools

    public class FileTools

extends java.lang.Object

File manipulation utilities.

Version:
  1.0

  Version History

      EPG - Initial - 24 NOV 04

Author:
  Erich P. Gatejen

Constructor Summary
`FileTools()`

Method Summary
`static java.io.File` | `appendFile(java.lang.String name)` Make a file.
`static void` | `copy(java.io.File source, java.io.File destination)` Copy a file.
`static void` | `copy(java.io.InputStream source, java.io.OutputStream destination)` Copy a stream.
`static void` | `delete(java.io.File theFile)` Delete a file.
`static void` | `destroy(java.io.File theFile)` Destroy a file or directory and all it's contents (including sub directories).
`static boolean` | `detectRelativePath(java.lang.String path)` This will detect if the path has any relative pointers (such as ..).
`static java.lang.String` | `loadFile2String(java.io.File path)` Read a file into a String.
`static int` | `loadStream2Buffer(java.io.InputStream stream, byte[] buffer)` Read a stream into a buffer, as much as can fit in the buffer, .
`static java.io.File` | `makeFile(java.lang.String name)` Make a file.
`static void` | `saveString2File(java.io.File path, java.lang.String theString)` Save 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

### FileTools

    public FileTools()

Method Detail

### copy

    public static void copy(java.io.File source,
                            java.io.File destination)
                     throws java.lang.Throwable

  Copy a file.

  Parameters:
    `source` -
    `destination` -
  Throws:
    `java.lang.Throwable`

### copy

    public static void copy(java.io.InputStream source,
                            java.io.OutputStream destination)
                     throws java.lang.Throwable

  Copy a stream. I'll implement this myself some day.

  Parameters:
    `source` -
    `destination` -
  Throws:
    `java.lang.Throwable`

### delete

    public static void delete(java.io.File theFile)
                       throws java.lang.Throwable

  Delete a file.

  Parameters:
    `theFile` - the file. Null will be ignored.
  Throws:
    `java.lang.Throwable`

### destroy

    public static void destroy(java.io.File theFile)
                        throws java.lang.Throwable

  Destroy a file or directory and all it's contents (including sub directories).

  Parameters:
    `theFile` - the file to destroy (it can be a real file or a directory).
  Throws:
    `java.lang.Throwable`

### makeFile

    public static java.io.File makeFile(java.lang.String name)
                                 throws java.lang.Throwable

  Make a file. If the file already exists, delete it. It will let any exception escape.

  Parameters:
    `name` - Path to the file
  Returns:
    A file object
  Throws:
    `java.lang.Throwable`

### appendFile

    public static java.io.File appendFile(java.lang.String name)
                                   throws java.lang.Exception

  Make a file. If the file already exists, it will be available for write. It will let any exception escape.

  Parameters:
    `name` - Path to the file
  Returns:
    A file object
  Throws:
    `java.lang.Exception`

### detectRelativePath

    public static boolean detectRelativePath(java.lang.String path)

  This will detect if the path has any relative pointers (such as ..).

  Parameters:
    `path` - The path
  Returns:
    true if it does, otherwise false.

### loadFile2String

    public static java.lang.String loadFile2String(java.io.File path)
                                            throws java.io.IOException

  Read a file into a String. This should be used only is absolutely needed.

  Parameters:
    `path` - File to load
  Returns:
    String if successful or otherwise null
  Throws:
    `Certain` - IOException, like if the file cannot be found or opened.
    `java.io.IOException`

### loadStream2Buffer

    public static int loadStream2Buffer(java.io.InputStream stream,
                                        byte[] buffer)
                                 throws java.io.IOException

  Read a stream into a buffer, as much as can fit in the buffer, . This should be used only is absolutely needed.

  Parameters:
    `stream` - the input stream
    `buffer` - the buffer;
  Returns:
    the number of bytes read intot he buffer.
  Throws:
    `Certain` - IOException, like if the file cannot be found or opened.
    `java.io.IOException`

### saveString2File

    public static void saveString2File(java.io.File path,
                                       java.lang.String theString)
                                throws java.io.IOException

  Save a string to a file. This should be used only is absolutely needed.

  Parameters:
    `path` - File to save
    `theString` - the string.
  Throws:
    `Certain` - IOException, like if the file cannot be found or opened.
    `java.io.IOException`

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

Things.