jut.io
Class Files

java.lang.Object
  extended by jut.io.Files

public final class Files
extends Object

static file utility methods.


Nested Class Summary
(package private) static interface Files.ExtendedInfoSetter
          interface used for setExtendedInfoSetter(ExtendedInfoSetter).
 
Method Summary
static String getExtendedInfo(File file)
          returns extended information about a file, e.g. access control, hidden status, etc. by default always returns "" if no extended info getter is set using setExtendedInfoGetter(ParamCallable).
static File[] listFiles(File directory)
          returns an array of files contained in the given directory or null if the argument is not a directory or an I/O error occurs.
static String relPath(File directory, File file)
          returns the relative path of a file within a directory. if the file IS the directory, returns "". for obtaining the paths, simply File.getPath() is called, i.e., the file paths used in this method are not absolute or canonical.
static boolean setExtendedInfo(File file, String info)
          sets the extended information of file, e.g. access control, hidden status, etc. by default doesn't do anything if no Files.ExtendedInfoSetter is set by setExtendedInfoSetter(ExtendedInfoSetter).
static void setExtendedInfoGetter(ParamCallable<String,File> extInfoGetter)
          globally set the method for getting extended file information of files used by getExtendedInfo(File).
static void setExtendedInfoSetter(Files.ExtendedInfoSetter extInfoSetter)
          globally set the method for setting extended file information of files used by setExtendedInfo(File, String).
static void setListFilesHandler(ParamCallable<File[],File> listFilesHandler)
          globally set the method for getting the files contained in a directory used by listFiles(File). by setting a suitable method, e.g. an input speed limit can be implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

listFiles

public static File[] listFiles(File directory)
returns an array of files contained in the given directory or null if the argument is not a directory or an I/O error occurs.

if this method is used consequently, it can be used e.g. to implement an input speed limit.

Parameters:
directory - - the directory to return the contained files of.
Returns:
an array of files contained in the given directory or null if the argument is not a directory or an I/O error occurs.

setListFilesHandler

public static void setListFilesHandler(ParamCallable<File[],File> listFilesHandler)
globally set the method for getting the files contained in a directory used by listFiles(File). by setting a suitable method, e.g. an input speed limit can be implemented.

Parameters:
listFilesHandler - - the method to use by listFiles(File) for getting the files contained in a directory.

relPath

public static String relPath(File directory,
                             File file)
                      throws IllegalArgumentException
returns the relative path of a file within a directory. if the file IS the directory, returns "". for obtaining the paths, simply File.getPath() is called, i.e., the file paths used in this method are not absolute or canonical.

Parameters:
directory - - a directory.
file - - the file to get the relative path of.
Returns:
the relative path of a file within a directory.
Throws:
IllegalArgumentException - if the file is not contained in the directory.

getExtendedInfo

public static String getExtendedInfo(File file)
returns extended information about a file, e.g. access control, hidden status, etc. by default always returns "" if no extended info getter is set using setExtendedInfoGetter(ParamCallable).

Parameters:
file - - the file to get extended information for.
Returns:
extended information about a file, e.g. access control, hidden status, etc.

setExtendedInfoGetter

public static void setExtendedInfoGetter(ParamCallable<String,File> extInfoGetter)
globally set the method for getting extended file information of files used by getExtendedInfo(File).

Parameters:
extInfoGetter - - the method to use by getExtendedInfo(File) for getting extended file information.

setExtendedInfo

public static boolean setExtendedInfo(File file,
                                      String info)
sets the extended information of file, e.g. access control, hidden status, etc. by default doesn't do anything if no Files.ExtendedInfoSetter is set by setExtendedInfoSetter(ExtendedInfoSetter).

Parameters:
file - - the file to set extended information for.
info - - the extended information string.
Returns:
true if the extended information is set, otherwise false.

setExtendedInfoSetter

public static void setExtendedInfoSetter(Files.ExtendedInfoSetter extInfoSetter)
globally set the method for setting extended file information of files used by setExtendedInfo(File, String).

Parameters:
extInfoSetter - - the method to use by setExtendedInfo(File, String) for setting extended file information.