Util
Class PathTools

java.lang.Object
  extended by Util.PathTools

public class PathTools
extends java.lang.Object

Collection of file path related stuff

Author:
eliott bartley

Method Summary
static java.lang.String[] fileList(java.lang.String pathList)
          Build a file list of all the files in the specified directories matching the specified wildcard. pathList can contain several paths separated by a semi-colon (;) e.g.
static java.lang.String getAbsolutePath(java.lang.String relativePath)
          Turn a relative path or filename into an absolute one
static java.lang.String getAbsolutePath(java.lang.String relativePath, boolean addSlash)
          Turn a relative path or filename into an absolute one
static java.lang.String getAbsolutePath(java.lang.String relativePath, java.lang.String workingPath)
          Turn a relative path or filename into an absolute one, relative to a directory other than the current directory
static java.lang.String getAbsolutePath(java.lang.String relativePath, java.lang.String workingPath, boolean addSlash)
          Turn a relative path or filename into an absolute one, relative to a directory other than the current directory
static java.lang.String getRelativePath(java.lang.String absolutePath)
          Get relative path of absolutePath from the current directory.
static java.lang.String getRelativePath(java.lang.String absolutePath, boolean addSlash)
          Get relative path of absolutePath from the current directory, optionally appending the result with a path separator
static java.lang.String getRelativePath(java.lang.String absolutePath, java.lang.String workingPath)
          Get relative path of absolutePath from the current directory.
static java.lang.String getRelativePath(java.lang.String absolutePath, java.lang.String workingPath, boolean addSlash)
          Get relative path of absolutePath from workingPath, optionally appending the result with a path separator
static java.lang.String getSafePath(java.lang.String path)
          Ensure a path ends with a '/'
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAbsolutePath

public static java.lang.String getAbsolutePath(java.lang.String relativePath)
Turn a relative path or filename into an absolute one

Parameters:
relativePath - The relative path to convert to an absolute one
Returns:
The absolute path of the relativePath

getAbsolutePath

public static java.lang.String getAbsolutePath(java.lang.String relativePath,
                                               java.lang.String workingPath)
Turn a relative path or filename into an absolute one, relative to a directory other than the current directory

Parameters:
relativePath - The relative path to convert to an absolute one
workingPath - The home path from which the relative path is from. If this is null, the current working path is used
Returns:
The absolute path of the relativePath

getAbsolutePath

public static java.lang.String getAbsolutePath(java.lang.String relativePath,
                                               boolean addSlash)
Turn a relative path or filename into an absolute one

Parameters:
relativePath - The relative path to convert to an absolute one
addSlash - Specify true if returned path must end with a '/', false if it's not important
Returns:
The absolute path of the relativePath

getAbsolutePath

public static java.lang.String getAbsolutePath(java.lang.String relativePath,
                                               java.lang.String workingPath,
                                               boolean addSlash)
Turn a relative path or filename into an absolute one, relative to a directory other than the current directory

Parameters:
relativePath - The relative path to convert to an absolute one
addSlash - Specify true if returned path must end with a '/', false if it's not important
Returns:
The absolute path of the relativePath

getRelativePath

public static java.lang.String getRelativePath(java.lang.String absolutePath)
Get relative path of absolutePath from the current directory. The resulting path will end with a path separator

Parameters:
absolutePath - file to generate path for
Returns:
path from workingPath to absolutePath as a string

getRelativePath

public static java.lang.String getRelativePath(java.lang.String absolutePath,
                                               boolean addSlash)
Get relative path of absolutePath from the current directory, optionally appending the result with a path separator

Parameters:
absolutePath - file to generate path for
addSlash - true to terminate the result with a path separator
Returns:
path from workingPath to absolutePath as a string

getRelativePath

public static java.lang.String getRelativePath(java.lang.String absolutePath,
                                               java.lang.String workingPath)
Get relative path of absolutePath from the current directory. The resulting path will end with a path separator

Parameters:
absolutePath - file to generate path for
workingPath - base path, should be a directory, not a file, or it doesn't make sense
Returns:
path from workingPath to absolutePath as a string

getRelativePath

public static java.lang.String getRelativePath(java.lang.String absolutePath,
                                               java.lang.String workingPath,
                                               boolean addSlash)
Get relative path of absolutePath from workingPath, optionally appending the result with a path separator

Parameters:
absolutePath - file to generate path for
workingPath - base path, should be a directory, not a file, or it doesn't make sense
addSlash - true to terminate the result with a path separator
Returns:
path from workingPath to absolutePath as a string

getSafePath

public static java.lang.String getSafePath(java.lang.String path)
Ensure a path ends with a '/'

Parameters:
path - The path to fix
Returns:
The path, with a trailing '/'

fileList

public static java.lang.String[] fileList(java.lang.String pathList)
Build a file list of all the files in the specified directories matching the specified wildcard. pathList can contain several paths separated by a semi-colon (;) e.g. "c:/.\*\.txt;c:/.\*\.dat" search for *.txt or *.dat in c:/. Wildcards use regular expression syntax e.g. "c:/[0-9]{5}\\.txt" search for files made up of 5 numeric digits followed by .txt. Wildcards can also appear in folder names, e.g. "c:/my .* /.*" search for all files under c that are in a folder starting my.. i.e. my document, my videos, etc. Folder searches can be recursive too, by starting the folder name with N: where N is the maximum depth of the search, or * for no limit, e.g. "c:/*:my .* /.*" search for all files under all folders in c: (search the whole drive) that start my.., or "c:/3:.* /.\*\.txt" search for .txt files in all folders up to a maximum of 3 levels deep, i.e. is the same as "c:/.* /.* /.* /.\*\.txt". Note: because \\ is regular expression syntax, it cannot be used as a path separator, use only / as a path separator

Parameters:
pathList - The list of semi-colon (;) separated paths to search
Returns:
Array of all files matching the path, includes pathname