org.apache.maven.doxia.util
public class FileUtil extends Object
Method Summary | |
---|---|
static void | copyFile(String srcFileName, String dstFileName)
Copy a file.
|
static String | defaultEncoding()
Returns the default character encoding for this platform.
|
static void | emptyDirectory(String dirName)
Recursively deletes all the entries of a directory.
|
static void | emptyDirectory(File dir)
Recursively deletes all the entries of a directory.
|
static String | fileBaseName(String fileName)
Returns the base name part in a file path name. |
static String | fileDirName(String fileName)
Returns the directory part in a file path name. |
static String | fileExtension(String fileName)
Returns the file extension part in a file path name. |
static URL | fileToURL(File file)
Converts a File to a file: URL.
|
static URL | fileToURL(String fileName)
Converts a file name to a file: URL.
|
static String | fileToURLName(String fileName)
Converts a file name to a file: URL name.
|
static boolean | isGzipped(String fileName)
Tests if a file has been compressed using gzip.
|
static byte[] | loadBytes(String fileName)
Loads the content of a binary file.
|
static byte[] | loadBytes(URL url)
Loads the content of an URL containing binary data.
|
static byte[] | loadBytes(InputStream source)
Loads the content of an InputStream returning binary data.
|
static String | loadGzippedString(String fileName)
Loads the content of a text file compressed using gzip.
|
static String | loadGzippedString(URL url)
Loads the content of an URL containing text compressed using gzip.
|
static String | loadGzippedString(InputStream source, String encoding)
Loads the content of an InputStream returning text compressed using
gzip.
|
static String | loadString(String fileName)
Loads the content of a text file.
|
static String | loadString(URL url)
Loads the content of an URL containing text.
|
static String | loadString(InputStream stream)
Loads the content of an InputStream returning text.
|
static void | main(String[] args)
A simple test for all functions dealing with file path names. |
static boolean | removeFile(String fileName)
Deletes a file or an empty directory.
|
static boolean | removeFile(String fileName, boolean force)
Deletes a file or a directory, possibly emptying the directory before
deleting it.
|
static boolean | removeFile(File file, boolean force)
Deletes a file or a directory, possibly emptying the directory before
deleting it.
|
static void | saveString(String string, String fileName)
Saves some text to a file.
|
static void | saveString(String string, OutputStream stream)
Saves some text to an OutputStream.
|
static String | trimFileExtension(String fileName)
Returns a file path name without its file extension part. |
static File | urlToFile(URL url)
Converts a file: URL to a File.
|
static File | urlToFile(String urlName)
Converts a file: URL name to a File.
|
static String | urlToFileName(String urlName)
Converts a file: URL name to a file name.
|
Parameters: srcFileName the name of the copied file dstFileName the name of the copy
Throws: IOException if there is an IO problem
Returns: default character encoding for this platform
Parameters: dirName the name of the directory to be emptied
Parameters: dir the directory to be emptied
On Windows, '/' is used as an alternate file path name separator.
Path | Result |
---|---|
util/FileUtil.java | FileUtil.java |
FileUtil.java | FileUtil.java |
Parameters: fileName a file path name
Returns: the base name part
On Windows, '/' is used as an alternate file path name separator.
Examples:
Path | Result |
---|---|
util/FileUtil.java | util |
FileUtil.java | . (dot) |
Parameters: fileName a file path name
Returns: the directory part
On Windows, '/' is used as an alternate file path name separator.
Path | Result |
---|---|
util/FileUtil.java | .java |
makefile | "" (empty string) |
/home/hussein/.profile | "" (empty string) |
Parameters: fileName a file path name
Returns: the file extension part; does not include the dot
If the base name without its extension is empty, the path is
considered not to have an extension part. This is the case of
/home/hussein/.profile in the examples above.
Parameters: file the file to be converted
Returns: the result of the conversion
Parameters: fileName the file name to be converted
Returns: the result of the conversion
Parameters: fileName the file name to be converted
Returns: the result of the conversion
Parameters: fileName the name of the file to be tested
Returns: true
if the file has been gzip-ed,
false
otherwise
Throws: IOException if there is an IO problem
Parameters: fileName the name of the binary file
Returns: the loaded bytes
Throws: IOException if there is an IO problem
Parameters: url the URL of the binary data
Returns: the loaded bytes
Throws: IOException if there is an IO problem
Parameters: source the binary data source
Returns: the loaded bytes
Throws: IOException if there is an IO problem
Parameters: fileName the name of the gzip-ed file; the encoding of the text before compression is assumed to be the default encoding of the platform
Returns: the loaded String
Throws: IOException if there is an IO problem
See Also: FileUtil
Parameters: url the URL of the gzip-ed data; the encoding of the text before compression is assumed to be the default encoding of the platform
Returns: the loaded String
Throws: IOException if there is an IO problem
See Also: FileUtil
Parameters: source the gzip-ed data source encoding the encoding of the text before compression
Returns: the loaded String
Throws: IOException if there is an IO problem
Parameters: fileName the name of the text file
Returns: the loaded String
Throws: IOException if there is an IO problem
Parameters: url the URL of the text resource
Returns: the loaded String
Throws: IOException if there is an IO problem
Parameters: stream the text source
Returns: the loaded String
Throws: IOException if there is an IO problem
Parameters: fileName the name of the file or empty directory to be deleted
Returns: true
if the file or directory has been
successfully deleted; false
otherwise
Parameters: fileName the name of the file or directory to be deleted force if true
and the file to be deleted is a
non-empty directory, empty it before attempting to delete it; if
false
, do not empty directories
Returns: true
if the file or directory has been
successfully deleted; false
otherwise
Parameters: file the file or directory to be deleted force if true
and the file to be deleted is a
non-empty directory, empty it before attempting to delete it; if
false
, do not empty directories
Returns: true
if the file or directory has been
successfully deleted; false
otherwise
Parameters: string the text to be saved fileName the name of the file
Throws: IOException if there is an IO problem
Parameters: string the text to be saved stream the text sink
Throws: IOException if there is an IO problem
On Windows, '/' is used as an alternate file path name separator.
Path | Result |
---|---|
util/FileUtil.java | util/FileUtil |
makefile | makefile |
/home/hussein/.profile | /home/hussein/.profile |
Parameters: fileName a file path name
Returns: the file path without extension part if any
Parameters: url the URL to be converted
Returns: the result of the conversion or null
if
url
is not a file: URL
Parameters: urlName the URL name to be converted
Returns: the result of the conversion or null
if
urlName
is not a file: URL
Parameters: urlName the URL name to be converted
Returns: the result of the conversion or null
if
urlName
is not a file: URL