|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.opencms.util.CmsFileUtil
Provides File utility functions.
| Method Summary | |
static void |
copy(String fromFile,
String toFile)
Simply version of a 1:1 binary file copy. |
static String |
formatFilesize(long filesize,
Locale locale)
Returns the formatted filesize to Bytes, KB, MB or GB depending on the given value. |
static List |
getFiles(String name,
FileFilter filter,
boolean includeSubtree)
Returns a list of all filtered files in the RFS. |
static String |
getResourcePathFromClassloader(String fileName)
Returns the absolute path name for the given relative path name if it was found by the context Classloader of the current Thread. |
static String |
normalizePath(String path)
Normalizes a file path that might contain '../' or './' or '//' elements to a normal absolute path, the path separator char is File.separatorChar. |
static String |
normalizePath(String path,
char separatorChar)
Normalizes a file path that might contain '../' or './' or '//' elements to a normal absolute path. |
static void |
purgeDirectory(File directory)
Deletes a directory in the file system and all subfolders of that directory. |
static byte[] |
readFile(String filename)
Reads a file from the RFS and returns the file content. |
static String |
readFile(String filename,
String encoding)
Reads a file from the RFS and converts it to a String with the specified encoding. |
static String |
searchWebInfFolder(String startFolder)
Searches for the OpenCms web application 'WEB-INF' folder during system startup, code or null if the 'WEB-INF' folder can not be found. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static void copy(String fromFile,
String toFile)
throws IOException
fromFile - the name of the file to copytoFile - the name of the target file
IOException - if any IO error occurs during the copy operation
public static String formatFilesize(long filesize,
Locale locale)
filesize - in byteslocale - the locale of the current OpenCms user or the System's default locale if the first choice
is not at hand.
public static List getFiles(String name,
FileFilter filter,
boolean includeSubtree)
If the name is not a folder the folder that contains the
given file will be used instead.
Despite the filter may not accept folders, every subfolder is traversed
if the includeSubtree parameter is set.
name - a folder or file namefilter - a filterincludeSubtree - if to include subfolders
File objectspublic static String getResourcePathFromClassloader(String fileName)
The argument has to denote a resource within the Classloaders
scope. A implementation for example would
try to match a given path name to some resource under it's URL
entries.URLClassLoader
As the result is internally obtained as an URL it is reduced to
a file path by the call to . Therefore
the returned String will start with a '/' (no problem for java.io).URL.getFile()
fileName - the filename to return the path from the Classloader for
Thread.getContextClassLoader()public static String normalizePath(String path)
File.separatorChar.
path - the path to normalize
public static String normalizePath(String path,
char separatorChar)
Can also handle Windows like path information containing a drive letter,
like C:\path\..\.
path - the path to normalizeseparatorChar - the file separator char to use, for example File.separatorChar
public static void purgeDirectory(File directory)
directory - the directory to delete
public static byte[] readFile(String filename)
throws IOException
filename - the file to read
IOException - in case of file access errors
public static String readFile(String filename,
String encoding)
throws IOException
filename - the file to readencoding - the encoding to use when converting the file content to a String
IOException - in case of file access errorspublic static String searchWebInfFolder(String startFolder)
null if the 'WEB-INF' folder can not be found.
startFolder - the folder where to start searching
null
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||