public final class FileTools
extends java.lang.Object
| Constructor and Description |
|---|
FileTools() |
| 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.
|
public static java.lang.String getRelativePath(java.io.File home,
java.io.File file)
home = /a/b/c file = /a/d/e/x.txt path = getRelativePath(home,file) = ../../d/e/x.txt
home - base path (should be a directory, not a file, or it doesn't make sense)file - file to generate relative path forpublic static final void copy(java.io.File src,
java.io.File dst)
throws java.io.IOException
java.io.IOExceptionpublic static final void setSeparator(java.lang.String s)
public static final void setSeparator(char c)
public static final int dotPosition(java.lang.String name)
public static final boolean hasDot(java.lang.String name)
public static final java.lang.String simpleName(java.lang.String name)
public static final java.lang.String simpleName(java.io.File file)
public static final java.lang.String prefix(java.lang.String name)
public static final java.lang.String fullPrefix(java.lang.String name)
public static final java.lang.String prefix(java.io.File file)
public static final java.lang.String extension(java.lang.String name)
public static final java.lang.String suffix(java.lang.String name)
public static final java.lang.String suffixIfDot(java.lang.String name)
public static final java.lang.String suffix(java.io.File file)
public static final java.lang.String dir(java.lang.String name)
public static final java.lang.String dir(java.io.File file)