FileTools (API documentation of hlt.language packages)
Date: 2013-01-30

hlt.language.io

## Class FileTools

- java.lang.Object
- - hlt.language.io.FileTools

-     public final class FileTools
      extends java.lang.Object

  This class defines some simple static functions that manipulate file names. It has no constructor since all its methods are static and accessible through the class name.
  Version:
    Last modified on Fri Oct 19 17:32:08 2012 by hak
  Author:
    Hassan Aït-Kaci
  Copyright:
    © by the author

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileTools()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `copy(java.io.File src, java.io.File dst)` Copies src file to dst file.
    `static java.lang.String` | `dir(java.io.File file)` Returns the directory part of the specified file.
    `static java.lang.String` | `dir(java.lang.String name)` Returns the directory part of the specified file name.
    `static int` | `dotPosition(java.lang.String name)` Returns the position of the dot marking the file's extension, or -1 if there is none.
    `static java.lang.String` | `extension(java.lang.String name)` Returns the extension of the specified file name.
    `static java.lang.String` | `fullPrefix(java.lang.String name)` Returns the absolute prefix of the specified file name.
    `static java.lang.String` | `getRelativePath(java.io.File home, java.io.File file)` Gets the relative path of File `file` with respect to `home` directory.
    `static boolean` | `hasDot(java.lang.String name)` Returns true iff the specified name has an extension dot (though not necessarily an extension).
    `static java.lang.String` | `prefix(java.io.File file)` Returns the name prefix of the specified file.
    `static java.lang.String` | `prefix(java.lang.String name)` Returns the relative prefix of the specified file name.
    `static void` | `setSeparator(char c)`
    `static void` | `setSeparator(java.lang.String s)`
    `static java.lang.String` | `simpleName(java.io.File file)` Returns the `name.ext` form of the specified file.
    `static java.lang.String` | `simpleName(java.lang.String name)` Returns the `name.ext` form of the specified file name.
    `static java.lang.String` | `suffix(java.io.File file)` Returns the suffix of the specified file.
    `static java.lang.String` | `suffix(java.lang.String name)` Returns the suffix of the specified file name.
    `static java.lang.String` | `suffixIfDot(java.lang.String name)` Returns the suffix of the specified file name, or the name as is if it contains no dot.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FileTools

          public FileTools()

  - ### Method Detail

    - #### getRelativePath

          public static java.lang.String getRelativePath(java.io.File home,
                                         java.io.File file)

      Gets the relative path of File `file` with respect to `home` directory. Example:

          home = /a/b/c
          file = /a/d/e/x.txt
          path = getRelativePath(home,file) = ../../d/e/x.txt

      Parameters:
        `home` - base path (should be a directory, not a file, or it doesn't make sense)
        `file` - file to generate relative path for
      Returns:
        path from home to file as a string

    - #### copy

          public static final void copy(java.io.File src,
                  java.io.File dst)
                                 throws java.io.IOException

      Copies src file to dst file. If the dst file does not exist, it is created.
      Throws:
        `java.io.IOException`

    - #### setSeparator

          public static final void setSeparator(java.lang.String s)

    - #### setSeparator

          public static final void setSeparator(char c)

    - #### dotPosition

          public static final int dotPosition(java.lang.String name)

      Returns the position of the dot marking the file's extension, or -1 if there is none. Note that if `name = foo.bar/baz`, this returns -1.

    - #### hasDot

          public static final boolean hasDot(java.lang.String name)

      Returns true iff the specified name has an extension dot (though not necessarily an extension).

    - #### simpleName

          public static final java.lang.String simpleName(java.lang.String name)

      Returns the `name.ext` form of the specified file name.

    - #### simpleName

          public static final java.lang.String simpleName(java.io.File file)

      Returns the `name.ext` form of the specified file.

    - #### prefix

          public static final java.lang.String prefix(java.lang.String name)

      Returns the relative prefix of the specified file name.

    - #### fullPrefix

          public static final java.lang.String fullPrefix(java.lang.String name)

      Returns the absolute prefix of the specified file name.

    - #### prefix

          public static final java.lang.String prefix(java.io.File file)

      Returns the name prefix of the specified file.

    - #### extension

          public static final java.lang.String extension(java.lang.String name)

      Returns the extension of the specified file name.

    - #### suffix

          public static final java.lang.String suffix(java.lang.String name)

      Returns the suffix of the specified file name.

    - #### suffixIfDot

          public static final java.lang.String suffixIfDot(java.lang.String name)

      Returns the suffix of the specified file name, or the name as is if it contains no dot.

    - #### suffix

          public static final java.lang.String suffix(java.io.File file)

      Returns the suffix of the specified file.

    - #### dir

          public static final java.lang.String dir(java.lang.String name)

      Returns the directory part of the specified file name.

    - #### dir

          public static final java.lang.String dir(java.io.File file)

      Returns the directory part of the specified file.