|
deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.deegree.commons.utils.FileUtils
public class FileUtils
This class contains static utility methods for handling files and filenames.
Constructor Summary | |
---|---|
FileUtils()
|
Method Summary | |
---|---|
static List<File> |
findFilesForExtensions(File topDirectory,
boolean recurse,
String patternList)
Find the files in the given directory (and sub-directories) which match the given extension pattern(s). |
static File |
getAsFile(URL url)
Converts a file:/... |
static String |
getBasename(File file)
Returns the filename, without any extension. |
static String |
getFileExtension(File file)
Returns the file extension (Eg. |
static String |
getFilename(File file)
Returns the filename, without any extension and path (Eg. |
static URL |
loadDeegreeConfiguration(Class<?> configurationClass,
String fileName)
A helper method which will try to load the given configuration file (name) from the root directory before trying to load it from the package of the given configuration class. |
static void |
writeBinaryFile(File file,
byte[] data)
Writes the given binary data to the specified file. |
static void |
writeBinaryTempFile(String filePrefix,
String fileSuffix,
byte[] data)
Writes the given binary data to a temporary file (created from specified prefix and suffix). |
static void |
writeFile(File file,
String content)
Writes the given String to the specified file. |
static void |
writeTempFile(String filePrefix,
String fileSuffix,
String content)
Writes the given String to a temporary file (created from specified prefix and suffix). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileUtils()
Method Detail |
---|
public static String getFilename(File file)
file
-
null
if the file is null;public static String getBasename(File file)
file
-
public static String getFileExtension(File file)
file
-
public static URL loadDeegreeConfiguration(Class<?> configurationClass, String fileName)
The org.deegree.geometry.GeometryFactory wants to load the File geometry_config.xml located in
org.deegree.geometry.configuration (hence the filename will be configuration/geometry_config.xml)
. This method will first try to read geometry_config.xml (without the 'configuration' directory from the
given fileName) from the root directory '/' (e.g. WEB-INF/classes in a serlvet environment)
If this was unsuccessful this method will try to load the file from the given packageName with the relative
fileName appended to it.
configurationClass
- will be used to read the stream from.fileName
- name of the file to read.
null
if the given file could not be read (in either location) or
either of the given parameters is null
.public static void writeFile(File file, String content)
String
to the specified file.
file
- file to write tocontent
- public static void writeTempFile(String filePrefix, String fileSuffix, String content)
String
to a temporary file (created from specified prefix and suffix).
filePrefix
- prefix for the temp file name, must be at least three characters longfileSuffix
- suffix for the temp file name, can be null (then ".tmp" is used)content
- File.createTempFile(String, String)
public static void writeBinaryFile(File file, byte[] data)
file
- file to write todata
- binary data to be writtenpublic static void writeBinaryTempFile(String filePrefix, String fileSuffix, byte[] data)
filePrefix
- prefix for the temp file name, must be at least three characters longfileSuffix
- suffix for the temp file name, can be null (then ".tmp" is used)data
- binary data to be writtenFile.createTempFile(String, String)
public static File getAsFile(URL url) throws IllegalArgumentException
file:/...
URL
into a file.
NOTE: The implementation uses an idea from Kohsuke Kawaguchi.
url
- file:/...
URL
IllegalArgumentException
- if the given URL is not a file:/...
URLpublic static List<File> findFilesForExtensions(File topDirectory, boolean recurse, String patternList)
topDirectory
- to start the search from.recurse
- patternList
- comma seperated list of extensions to search for.
|
deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |