|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.arakhne.vmutil.FileSystem
public class FileSystem
An utility class that permits to deal with filenames.
| Field Summary | |
|---|---|
static String |
CURRENT_DIRECTORY
String which is representing the current directory in a relative path. |
static String |
EXTENSION_SEPARATOR
String used to specify a file extension. |
static char |
EXTENSION_SEPARATOR_CHAR
Character used to specify a file extension. |
static String |
JAR_URL_FILE_ROOT
Prefix used to join in a Jar URL the jar filename and the inside-jar filename. |
static String |
PARENT_DIRECTORY
String which is representing the parent directory in a relative path. |
static String |
URL_PATH_SEPARATOR
Character used to separate paths on an URL. |
static char |
URL_PATH_SEPARATOR_CHAR
Character used to separate paths on an URL. |
| Constructor Summary | |
|---|---|
FileSystem()
|
|
| Method Summary | |
|---|---|
static File |
addExtension(File filename,
String extension)
Add the extension of to specified filename. |
static URL |
addExtension(URL filename,
String extension)
Add the extension of to specified filename. |
static String |
basename(File filename)
Reply the basename of the specified file without the last extension. |
static String |
basename(String filename)
Reply the basename of the specified file without the last extension. |
static String |
basename(URL filename)
Reply the basename of the specified file without the last extension. |
static URL |
convertFileToURL(File file)
Replies an URL for the given file and translate it into a resource URL if the given file is inside the classpath. |
static URL |
convertStringToUrl(String urlDescription,
boolean allowResourceSearch)
Deprecated. see convertStringToURL(String, boolean) |
static URL |
convertStringToURL(String urlDescription,
boolean allowResourceSearch)
Convert a string to an URL according to several rules. |
static URL |
convertStringToUrl(String urlDescription,
boolean allowResourceSearch,
boolean repliesFileURL)
Deprecated. convertStringToURL(String, boolean, boolean) |
static URL |
convertStringToURL(String urlDescription,
boolean allowResourceSearch,
boolean repliesFileURL)
Convert a string to an URL according to several rules. |
(package private) static URL |
convertStringToURL(String urlDescription,
boolean allowResourceSearch,
boolean repliesFileURL,
boolean supportWindowsPaths)
Convert a string to an URL according to several rules. |
static File |
convertUrlToFile(URL url)
Deprecated. convertURLToFile(URL) |
static File |
convertURLToFile(URL url)
Convert an URL which represents a local file into a File. |
static void |
copy(File in,
File out)
Copy the first file into the second file. |
static void |
copy(InputStream in,
int inSize,
FileOutputStream out)
Copy the first file into the second file. |
static void |
copy(URL in,
File out)
Copy the first file into the second file. |
static File |
createTempDirectory(String prefix,
String suffix)
Create an empty directory in the default temporary-file directory, using the given prefix and suffix to generate its name. |
static File |
createTempDirectory(String prefix,
String suffix,
File directory)
Creates a new empty directory in the specified directory, using the given prefix and suffix strings to generate its name. |
static void |
delete(File file)
Delete the given directory and all its subdirectories. |
static void |
deleteOnExit(File file)
Delete the given directory and all its subdirectories when the JVM is exiting. |
static URL |
dirname(File filename)
Replies the dirname of the specified file. |
static URL |
dirname(URL filename)
Replies the dirname of the specified file. |
static String |
extension(File filename)
Reply the extension of the specified file. |
static String |
extension(URL filename)
Reply the extension of the specified file. |
static String[] |
extensions(File filename)
Reply all the extensions of the specified file. |
static String[] |
extensions(URL filename)
Reply all the extensions of the specified file. |
static void |
fileCopy(File in,
File out)
Deprecated. copy(File, File) |
static void |
fileCopy(URL in,
File out)
Deprecated. copy(URL, File) |
static char |
getFileExtensionCharacter()
Replies the character used to separate the basename and the file extension. |
static File |
getJarFile(URL url)
Replies the file part of the jar-scheme URL. |
static URL |
getJarURL(URL url)
Replies the jar part of the jar-scheme URL. |
static URL |
getParentURL(URL url)
Replies the parent URL for the given URL. |
static File |
getSystemConfigurationDirectoryFor(String software)
Replies the system configuration directory for the specified software. |
static String |
getSystemConfigurationDirectoryNameFor(String software)
Replies the user configuration directory for the specified software. |
static File |
getSystemSharedLibraryDirectoryFor(String software)
Replies the system shared library directory for the specified software. |
static String |
getSystemSharedLibraryDirectoryNameFor(String software)
Replies the system shared library directory for the specified software. |
static File |
getUserConfigurationDirectoryFor(String software)
Replies the user configuration directory for the specified software. |
static String |
getUserConfigurationDirectoryNameFor(String software)
Replies the user configuration directory for the specified software. |
static File |
getUserHomeDirectory()
Replies the user home directory. |
static String |
getUserHomeDirectoryName()
Replies the user home directory. |
static boolean |
hasExtension(File filename,
String extension)
Replies if the specified file has the specified extension. |
static boolean |
hasExtension(URL filename,
String extension)
Replies if the specified file has the specified extension. |
static boolean |
isCaseSensitiveFilenameSystem()
Replies if the current operating system uses case-sensitive filename. |
static boolean |
isFileBasedScheme(URISchemeType scheme)
Deprecated. see URISchemeType.isFileBasedScheme() |
static boolean |
isFileBasedURL(URL url)
Deprecated. see URISchemeType.isFileBasedScheme() |
static boolean |
isJarURL(URL url)
Replies if the given URL has a jar scheme. |
static boolean |
isWindowsNativeFilename(String filename)
Replies if the given string contains a Windows® native long filename. |
static File |
join(File fileBase,
File... elements)
Join the parts of a path and append them to the given File. |
static File |
join(File fileBase,
String... elements)
Join the parts of a path and append them to the given File. |
static URL |
join(URL urlBase,
File... elements)
Join the parts of a path and append them to the given URL. |
static URL |
join(URL urlBase,
String... elements)
Join the parts of a path and append them to the given URL. |
static String |
largeBasename(File filename)
Replies the basename of the specified file with the extension. |
static String |
largeBasename(String filename)
Replies the basename of the specified file with the extension. |
static String |
largeBasename(URL filename)
Replies the basename of the specified file with the extension. |
static File |
makeAbsolute(File filename,
File current)
Make the given filename absolute from the given root if it is not already absolute. |
static URL |
makeAbsolute(File filename,
URL current)
Make the given filename absolute from the given root if it is not already absolute. |
static URL |
makeAbsolute(URL filename,
File current)
Make the given filename absolute from the given root if it is not already absolute. |
static URL |
makeAbsolute(URL filename,
URL current)
Make the given filename absolute from the given root if it is not already absolute. |
static URL |
makeCanonicalURL(URL url)
A canonical pathname is both absolute and unique. |
static File |
makeRelative(File filenameToMakeRelative,
File rootPath)
Make the given filename relative to the given root path. |
static File |
makeRelative(File filenameToMakeRelative,
URL rootPath)
Make the given filename relative to the given root path. |
static File |
makeRelative(URL filenameToMakeRelative,
URL rootPath)
Make the given filename relative to the given root path. |
static File |
normalizeWindowsNativeFilename(String filename)
Normalize the given string contains a Windows® native long filename and replies a Java-standard version. |
static File |
removeExtension(File filename)
Remove the extension from the specified filename. |
static URL |
removeExtension(URL filename)
Remove the extension from the specified filename. |
static File |
replaceExtension(File filename,
String extension)
Replace the extension of the specified filename by the given extension. |
static URL |
replaceExtension(URL filename,
String extension)
Replace the extension of the specified filename by the given extension. |
static String |
shortBasename(File filename)
Reply the basename of the specified file without all the extensions. |
static String |
shortBasename(String filename)
Reply the basename of the specified file without all the extensions. |
static String |
shortBasename(URL filename)
Reply the basename of the specified file without all the extensions. |
static String[] |
split(File filename)
Replies the parts of a path. |
static String[] |
split(URL filename)
Replies the parts of a path. |
static URL |
toJarURL(File jarFile,
File insideFile)
Replies the jar-schemed URL composed of the two given components. |
static URL |
toJarURL(File jarFile,
String insideFile)
Replies the jar-schemed URL composed of the two given components. |
static URL |
toJarURL(URL jarFile,
File insideFile)
Replies the jar-schemed URL composed of the two given components. |
static URL |
toJarURL(URL jarFile,
String insideFile)
Replies the jar-schemed URL composed of the two given components. |
static URL |
toShortestURL(URL url)
Replies an URL for the given url and translate it into a resource URL if the given file is inside the classpath. |
static void |
undeleteOnExit(File file)
Cancel the deletion of the given directory and all its subdirectories when the JVM is exiting. |
static void |
unzipFile(File input,
File output)
Unzip a file into the output directory. |
static void |
unzipFile(InputStream input,
File output)
Unzip the given stream and write out the file in the output. |
static void |
zipFile(File input,
File output)
Create a zip file from the given input file. |
static void |
zipFile(File input,
OutputStream output)
Create a zip file from the given input file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char EXTENSION_SEPARATOR_CHAR
public static final String CURRENT_DIRECTORY
public static final String PARENT_DIRECTORY
public static final char URL_PATH_SEPARATOR_CHAR
public static final String URL_PATH_SEPARATOR
public static final String EXTENSION_SEPARATOR
public static final String JAR_URL_FILE_ROOT
| Constructor Detail |
|---|
public FileSystem()
| Method Detail |
|---|
public static boolean isJarURL(URL url)
url -
true if the given URL uses a jar scheme.public static URL getJarURL(URL url)
url -
null
if the given URL does not use jar scheme.public static File getJarFile(URL url)
url -
null
if the given URL does not use jar scheme.
public static URL toJarURL(File jarFile,
File insideFile)
throws MalformedURLException
jarFile - is the URL to the jar file.insideFile - is the name of the file inside the jar.
MalformedURLException - when the URL is malformed.
public static URL toJarURL(File jarFile,
String insideFile)
throws MalformedURLException
jarFile - is the URL to the jar file.insideFile - is the name of the file inside the jar.
MalformedURLException - when the URL is malformed.
public static URL toJarURL(URL jarFile,
File insideFile)
throws MalformedURLException
jarFile - is the URL to the jar file.insideFile - is the name of the file inside the jar.
MalformedURLException - when the URL is malformed.
public static URL toJarURL(URL jarFile,
String insideFile)
throws MalformedURLException
jarFile - is the URL to the jar file.insideFile - is the name of the file inside the jar.
MalformedURLException - when the URL is malformed.public static boolean isCaseSensitiveFilenameSystem()
true if the filenames on the current file system are case sensitive,
otherwise falsepublic static char getFileExtensionCharacter()
public static URL dirname(File filename)
filename - is the name to parse.
shortBasename(File),
largeBasename(File),
basename(File),
extension(File)public static URL dirname(URL filename)
filename - is the name to parse.
shortBasename(URL),
largeBasename(URL),
basename(URL),
extension(URL)public static String largeBasename(String filename)
Caution: This function does not support URL format.
filename - is the name to parse.
public static String largeBasename(File filename)
filename - is the name to parse.
public static String largeBasename(URL filename)
filename - is the name to parse.
public static String basename(String filename)
Caution: This function does not support URL format.
filename - is the name to parse.
shortBasename(String),
largeBasename(String)public static String basename(File filename)
filename - is the name to parse.
shortBasename(File),
largeBasename(File),
dirname(File),
extension(File)public static String basename(URL filename)
filename - is the name to parse.
shortBasename(URL),
largeBasename(URL),
dirname(URL),
extension(URL)public static String shortBasename(String filename)
Caution: This function does not support URL format.
filename - is the name to parse.
public static String shortBasename(File filename)
filename - is the name to parse.
public static String shortBasename(URL filename)
filename - is the name to parse.
public static String extension(File filename)
filename - is the name to parse.
shortBasename(File),
largeBasename(File),
basename(File),
dirname(File),
extensions(File)public static String extension(URL filename)
filename - is the name to parse.
shortBasename(URL),
largeBasename(URL),
basename(URL),
dirname(URL),
extensions(URL)public static String[] extensions(File filename)
filename - is the name to parse.
public static String[] extensions(URL filename)
filename - is the name to parse.
public static String[] split(File filename)
filename - is the name to parse.
public static String[] split(URL filename)
filename - is the name to parse.
public static File join(File fileBase,
String... elements)
fileBase - is the file to put as prefix.elements - are the path's elements to join.
public static File join(File fileBase,
File... elements)
fileBase - is the file to put as prefix.elements - are the path's elements to join.
public static URL join(URL urlBase,
String... elements)
urlBase - is the url to put as prefix.elements - are the path's elements to join.
public static URL join(URL urlBase,
File... elements)
urlBase - is the url to put as prefix.elements - are the path's elements to join.
public static boolean hasExtension(File filename,
String extension)
The test is dependent of the case-sensitive attribute of operating system.
filename - is the filename to parseextension - is the extension to test.
true if the given filename has the given extension,
otherwise false
public static boolean hasExtension(URL filename,
String extension)
The test is dependent of the case-sensitive attribute of operating system.
filename - is the filename to parseextension - is the extension to test.
true if the given filename has the given extension,
otherwise falsepublic static File removeExtension(File filename)
filename - is the filename to parse.
public static URL removeExtension(URL filename)
filename - is the filename to parse.
public static File replaceExtension(File filename,
String extension)
filename - is the filename to parse.extension - is the extension to remove if it is existing.
public static URL replaceExtension(URL filename,
String extension)
filename - is the filename to parse.extension - is the extension to remove if it is existing.
public static File addExtension(File filename,
String extension)
filename - is the filename to parse.extension - is the extension to remove if it is existing.
public static URL addExtension(URL filename,
String extension)
filename - is the filename to parse.extension - is the extension to remove if it is existing.
public static void delete(File file)
throws IOException
file - is the file to delete.
IOExceptionfor the deletion on a file only.,
to create a directory.,
to create a directory and all its parents.
public static void deleteOnExit(File file)
throws IOException
To cancel this action, see undeleteOnExit(File).
file - is the file to delete.
IOExceptionfor the deletion on a file only.,
to create a directory.,
to create a directory and all its parents.
public static void undeleteOnExit(File file)
throws IOException
file - is the file to undelete.
IOExceptiondeleteOnExit(File),
for the deletion on a file only.,
to create a directory.,
to create a directory and all its parents.
@Deprecated
public static void fileCopy(File in,
File out)
throws IOException
copy(File, File)
The content of the second file will be lost. This copy function allows to do a copy between two different partitions.
in - is the file to copy.out - is the target file
IOException - in case of error.fileCopy(URL, File)
public static void copy(File in,
File out)
throws IOException
The content of the second file will be lost. This copy function allows to do a copy between two different partitions.
If the out parameter is a directory, the output file is a file with the same basename as the input and inside the ou directory.
in - is the file to copy.out - is the target file
IOException - in case of error.copy(URL, File)
@Deprecated
public static void fileCopy(URL in,
File out)
throws IOException
copy(URL, File)
The content of the second file will be lost. This copy function allows to do a copy between two different partitions.
in - is the file to copy.out - is the target file
IOException - in case of error.fileCopy(File, File)
public static void copy(URL in,
File out)
throws IOException
The content of the second file will be lost. This copy function allows to do a copy between two different partitions.
in - is the file to copy.out - is the target file
IOException - in case of error.copy(File, File)
public static void copy(InputStream in,
int inSize,
FileOutputStream out)
throws IOException
The content of the second file will be lost. This copy function allows to do a copy between two different partitions.
in - is the input stream to read.inSize - is the total size of the input stream.out - is the output stream.
IOException
public static File getUserHomeDirectory()
throws FileNotFoundException
FileNotFoundExceptionpublic static String getUserHomeDirectoryName()
public static File getUserConfigurationDirectoryFor(String software)
On Unix operating systems, the user directory for a
software is by default $HOME/.software where software
is the given parameter (case-sensitive). On Windows® operating systems, the user
directory for a software is by default
C:<span>\</span>Documents and Settings<span>\</span>userName<span>\</span>Local Settings<span>\</span>Application Data<span>\</span>software
where userName is the login of the current user and software
is the given parameter (case-insensitive).
software - is the name of the concerned software.
public static String getUserConfigurationDirectoryNameFor(String software)
On Unix operating systems, the user directory for a
software is by default $HOME/.software where software
is the given parameter (case-sensitive). On Windows® operating systems, the user
directory for a software is by default
C:<span>\</span>Documents and Settings<span>\</span>userName<span>\</span>Local Settings<span>\</span>Application Data<span>\</span>software
where userName is the login of the current user and software
is the given parameter (case-insensitive).
software - is the name of the concerned software.
public static File getSystemConfigurationDirectoryFor(String software)
On Unix operating systems, the system directory for a
software is by default /etc/software where software
is the given parameter (case-sensitive). On Windows® operating systems, the user
directory for a software is by default
C:<span>\</span>Program Files<span>\</span>software
where software is the given parameter (case-insensitive).
software - is the name of the concerned software.
public static String getSystemConfigurationDirectoryNameFor(String software)
On Unix operating systems, the system directory for a
software is by default /etc/software where software
is the given parameter (case-sensitive). On Windows® operating systems, the user
directory for a software is by default
C:<span>\</span>Program Files<span>\</span>software
where software is the given parameter (case-insensitive).
software - is the name of the concerned software.
public static File getSystemSharedLibraryDirectoryFor(String software)
On Unix operating systems, the system directory for a
software is by default /usr/lib/software where software
is the given parameter (case-sensitive). On Windows® operating systems, the user
directory for a software is by default
C:<span>\</span>Program Files<span>\</span>software
where software is the given parameter (case-insensitive).
software - is the name of the concerned software.
public static String getSystemSharedLibraryDirectoryNameFor(String software)
On Unix operating systems, the system directory for a
software is by default /usr/lib/software where software
is the given parameter (case-sensitive). On Windows® operating systems, the user
directory for a software is by default
C:<span>\</span>Program Files<span>\</span>software
where software is the given parameter (case-insensitive).
software - is the name of the concerned software.
@Deprecated public static File convertUrlToFile(URL url)
convertURLToFile(URL)
url - is the URL to convert.
IllegalArgumentException - is the URL was malformed.public static File convertURLToFile(URL url)
url - is the URL to convert.
IllegalArgumentException - is the URL was malformed.
@Deprecated
public static URL convertStringToUrl(String urlDescription,
boolean allowResourceSearch)
convertStringToURL(String, boolean)
The rules are (the first succeeded is replied):
null or empty, return null;URL with urlDescription as parameter;true and
urlDescription starts with "resource:", call
Resources.getResource(String) with the rest of the string as parameter;true, call
Resources.getResource(String) with the urlDescription as
parameter;File.toURI() to retreive an URI and then
URI.toURL();null.
urlDescription - is a string which is describing an URL.allowResourceSearch - indicates if the convertion must take into account the Java resources.
IllegalArgumentException - is the string could not be formatted to URL.Resources.getResource(String)
public static URL convertStringToURL(String urlDescription,
boolean allowResourceSearch)
The rules are (the first succeeded is replied):
null or empty, return null;URL with urlDescription as parameter;true and
urlDescription starts with "resource:", call
Resources.getResource(String) with the rest of the string as parameter;true, call
Resources.getResource(String) with the urlDescription as
parameter;File.toURI() to retreive an URI and then
URI.toURL();null.
urlDescription - is a string which is describing an URL.allowResourceSearch - indicates if the convertion must take into account the Java resources.
IllegalArgumentException - is the string could not be formatted to URL.Resources.getResource(String)
@Deprecated
public static URL convertStringToUrl(String urlDescription,
boolean allowResourceSearch,
boolean repliesFileURL)
convertStringToURL(String, boolean, boolean)
The rules are (the first succeeded is replied):
null or empty, return null;URL with urlDescription as parameter;true and
urlDescription starts with "resource:", call
Resources.getResource(String) with the rest of the string as parameter;true, call
Resources.getResource(String) with the urlDescription as
parameter;true and
assuming that the urlDescription is
a filename, call File.toURI() to retreive an URI and then
URI.toURL();null.
urlDescription - is a string which is describing an URL.allowResourceSearch - indicates if the convertion must take into account the Java resources.repliesFileURL - indicates if urlDescription is allowed to be a filename.
IllegalArgumentException - is the string could not be formatted to URL.Resources.getResource(String)
public static URL convertStringToURL(String urlDescription,
boolean allowResourceSearch,
boolean repliesFileURL)
The rules are (the first succeeded is replied):
null or empty, return null;URL with urlDescription as parameter;true and
urlDescription starts with "resource:", call
Resources.getResource(String) with the rest of the string as parameter;true, call
Resources.getResource(String) with the urlDescription as
parameter;true and
assuming that the urlDescription is
a filename, call File.toURI() to retreive an URI and then
URI.toURL();null.
urlDescription - is a string which is describing an URL.allowResourceSearch - indicates if the convertion must take into account the Java resources.repliesFileURL - indicates if urlDescription is allowed to be a filename.
IllegalArgumentException - is the string could not be formatted to URL.Resources.getResource(String)
static URL convertStringToURL(String urlDescription,
boolean allowResourceSearch,
boolean repliesFileURL,
boolean supportWindowsPaths)
The rules are (the first succeeded is replied):
null or empty, return null;URL with urlDescription as parameter;true and
urlDescription starts with "resource:", call
Resources.getResource(String) with the rest of the string as parameter;true, call
Resources.getResource(String) with the urlDescription as
parameter;true and
assuming that the urlDescription is
a filename, call File.toURI() to retreive an URI and then
URI.toURL();null.
urlDescription - is a string which is describing an URL.allowResourceSearch - indicates if the convertion must take into account the Java resources.repliesFileURL - indicates if urlDescription is allowed to be a filename.supportWindowsPaths - indicates if Windows paths should be treated in particular way.
IllegalArgumentException - is the string could not be formatted to URL.Resources.getResource(String)
public static File makeAbsolute(File filename,
File current)
| filename | current | Result |
|---|---|---|
null |
null |
null |
null |
/myroot |
null |
/path/to/file |
null |
/path/to/file |
path/to/file |
null |
path/to/file |
/path/to/file |
/myroot |
/path/to/file |
path/to/file |
/myroot |
/myroot/path/to/file |
filename - is the name to make absolute.current - is the current directory which permits to make absolute.
@Deprecated public static boolean isFileBasedURL(URL url)
URISchemeType.isFileBasedScheme()
url -
true if the given url is a "file", "http",
"https", "ftp", "ssh", "jar" or "resource", otherwise false.@Deprecated public static boolean isFileBasedScheme(URISchemeType scheme)
URISchemeType.isFileBasedScheme()
scheme -
true if the given scheme is a "file", "http",
"https", "ftp", "ssh", "jar" or "resource", otherwise false.
public static URL makeAbsolute(URL filename,
File current)
| filename | current | Result |
|---|---|---|
null |
null |
null |
null |
/myroot |
null |
file:/path/to/file |
null |
file:/path/to/file |
file:path/to/file |
null |
file:path/to/file |
file:/path/to/file |
/myroot |
file:/path/to/file |
file:path/to/file |
/myroot |
file:/myroot/path/to/file |
http://host.com/path/to/file |
null |
http://host.com/path/to/file |
http://host.com/path/to/file |
/myroot |
http://host.com/path/to/file |
ftp://host.com/path/to/file |
null |
ftp://host.com/path/to/file |
ftp://host.com/path/to/file |
/myroot |
ftp://host.com/path/to/file |
ssh://host.com/path/to/file |
null |
ssh://host.com/path/to/file |
ssh://host.com/path/to/file |
/myroot |
ssh://host.com/path/to/file |
filename - is the name to make absolute.current - is the current directory which permits to make absolute.
public static URL makeAbsolute(URL filename,
URL current)
| filename | current | Result |
|---|---|---|
null |
null |
null |
null |
file:/myroot |
null |
null |
http://host.com/myroot |
null |
file:path/to/file |
null |
file:path/to/file |
file:path/to/file |
file:/myroot |
file:/myroot/path/to/file |
file:path/to/file |
http://host.com/myroot |
http://host.com/myroot/path/to/file |
file:/path/to/file |
null |
file:/path/to/file |
file:/path/to/file |
file:/myroot |
file:/path/to/file |
file:/path/to/file |
http://host.com/myroot |
file:/path/to/file |
http://host2.com/path/to/file |
null |
http://host2.com/path/to/file |
http://host2.com/path/to/file |
file:/myroot |
http://host2.com/path/to/file |
http://host2.com/path/to/file |
http://host.com/myroot |
http://host2.com/path/to/file |
ftp://host2.com/path/to/file |
null |
ftp://host2.com/path/to/file |
ftp://host2.com/path/to/file |
file:/myroot |
ftp://host2.com/path/to/file |
ftp://host2.com/path/to/file |
http://host.com/myroot |
ftp://host2.com/path/to/file |
filename - is the name to make absolute.current - is the current directory which permits to make absolute.
public static URL makeAbsolute(File filename,
URL current)
| filename | current | Result |
|---|---|---|
null |
null |
null |
null |
file:/myroot |
null |
null |
http://host.com/myroot |
null |
path/to/file |
null |
file:path/to/file |
path/to/file |
file:/myroot |
file:/myroot/path/to/file |
path/to/file |
http://host.com/myroot |
http://host.com/myroot/path/to/file |
/path/to/file |
null |
file:/path/to/file |
/path/to/file |
file:/myroot |
file:/path/to/file |
/path/to/file |
http://host.com/myroot |
file:/path/to/file |
filename - is the name to make absolute.current - is the current directory which permits to make absolute.
public static URL getParentURL(URL url)
throws MalformedURLException
url -
MalformedURLExceptionpublic static boolean isWindowsNativeFilename(String filename)
Long filenames (LFN), spelled "long file names" by Microsoft Corporation, are Microsoft's way of implementing filenames longer than the 8.3, or short-filename, naming scheme used in Microsoft DOS in their modern FAT and NTFS filesystems. Because these filenames can be longer than the 8.3 filename, they can be more descriptive. Another advantage of this scheme is that it allows for use of *nix files ending in (e.g. .jpeg, .tiff, .html, and .xhtml) rather than specialized shortened names (e.g. .jpg, .tif, .htm, .xht).
The long filename system allows a maximum length of 255 UTF-16 characters,
including spaces and non-alphanumeric characters; excluding the following
characters, which have special meaning within the command interpreter or
the operating system kernel: \ / :
* ? " <
> |
filename -
true if the given filename is a long filename,
otherwise falsenormalizeWindowsNativeFilename(String)public static File normalizeWindowsNativeFilename(String filename)
Long filenames (LFN), spelled "long file names" by Microsoft Corporation, are Microsoft's way of implementing filenames longer than the 8.3, or short-filename, naming scheme used in Microsoft DOS in their modern FAT and NTFS filesystems. Because these filenames can be longer than the 8.3 filename, they can be more descriptive. Another advantage of this scheme is that it allows for use of *nix files ending in (e.g. .jpeg, .tiff, .html, and .xhtml) rather than specialized shortened names (e.g. .jpg, .tif, .htm, .xht).
The long filename system allows a maximum length of 255 UTF-16 characters,
including spaces and non-alphanumeric characters; excluding the following
characters, which have special meaning within the command interpreter or
the operating system kernel: \ / :
* ? " <
> |
filename -
null if not a windows native path.isWindowsNativeFilename(String)public static URL convertFileToURL(File file)
file - is the filename to translate.
null if
the url cannot be computed.public static URL toShortestURL(URL url)
url - is the URL to make shortest.
null if
the url cannot be computed.
public static File makeRelative(File filenameToMakeRelative,
File rootPath)
throws IOException
filenameToMakeRelative - is the name to make relative.rootPath - is the root path from which the relative path will be set.
IOException - when is is impossible to retreive canonical paths.
public static File makeRelative(File filenameToMakeRelative,
URL rootPath)
throws IOException
filenameToMakeRelative - is the name to make relative.rootPath - is the root path from which the relative path will be set.
IOException - when is is impossible to retreive canonical paths.
public static File makeRelative(URL filenameToMakeRelative,
URL rootPath)
throws IOException
filenameToMakeRelative - is the name to make relative.rootPath - is the root path from which the relative path will be set.
IOException - when is is impossible to retreive canonical paths.public static URL makeCanonicalURL(URL url)
A canonical pathname is both absolute and unique. This method maps the pathname to its unique form. This typically involves removing redundant names such as "." and ".." from the pathname.
url - is the URL to make canonical
public static void zipFile(File input,
OutputStream output)
throws IOException
input - output -
IOException
public static void unzipFile(InputStream input,
File output)
throws IOException
input - output -
IOException
public static void zipFile(File input,
File output)
throws IOException
input - output -
IOException
public static void unzipFile(File input,
File output)
throws IOException
input - output -
IOException
public static File createTempDirectory(String prefix,
String suffix)
throws IOException
createTempDirectory(prefix, suffix, null).
prefix - is the prefix string to be used in generating the file's
name; must be at least three characters longsuffix - is the suffix string to be used in generating the file's
name; may be null, in which case the
suffix ".tmp" will be used
IllegalArgumentException - If the prefix argument contains fewer than three
characters
IOException - If a file could not be created
SecurityException - If a security manager exists and its SecurityManager.checkWrite(java.lang.String)
method does not allow a file to be created
public static File createTempDirectory(String prefix,
String suffix,
File directory)
throws IOException
This method provides only part of a temporary-file facility. To arrange
for a file created by this method to be deleted automatically, use the
method.
deleteOnExit(java.io.File)
The prefix argument must be at least three characters
long. It is recommended that the prefix be a short, meaningful string
such as "hjb" or "mail". The
suffix argument may be null, in which case the
suffix ".tmp" will be used.
To create the new directory, the prefix and the suffix may first be
adjusted to fit the limitations of the underlying platform. If the
prefix is too long then it will be truncated, but its first three
characters will always be preserved. If the suffix is too long then it
too will be truncated, but if it begins with a period character
('.') then the period and the first three characters
following it will always be preserved. Once these adjustments have been
made the name of the new file will be generated by concatenating the
prefix, five or more internally-generated characters, and the suffix.
If the directory argument is null then the
system-dependent default temporary-file directory will be used. The
default temporary-file directory is specified by the system property
java.io.tmpdir. On UNIX systems the default value of this
property is typically "/tmp" or "/var/tmp"; on
Microsoft Windows systems it is typically "C:\\WINNT\\TEMP". A different
value may be given to this system property when the Java virtual machine
is invoked, but programmatic changes to this property are not guaranteed
to have any effect upon the temporary directory used by this method.
prefix - is the prefix string to be used in generating the file's
name; must be at least three characters longsuffix - is the suffix string to be used in generating the file's
name; may be null, in which case the
suffix ".tmp" will be useddirectory - is the directory in which the file is to be created, or
null if the default temporary-file
directory is to be used
IllegalArgumentException - If the prefix argument contains fewer than three
characters
IOException - If a file could not be created
SecurityException - If a security manager exists and its SecurityManager.checkWrite(java.lang.String)
method does not allow a file to be created
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||