Class FileUtils
- java.lang.Object
-
- org.apache.commons.configuration2.io.FileUtils
-
final class FileUtils extends java.lang.Object
This class is a subset of org.apache.commons.io.FileUtils, git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1423916 13f79535-47bb-0310-9956-ffa450edef68. The subset is determined byFileLocatorUtils
. The copied constants and methods are literally copied.
See CONFIGURATION-521 for a discussion.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.nio.charset.Charset
UTF8
The UTF-8 character set, used to decode octets in URLs.
-
Constructor Summary
Constructors Constructor Description FileUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.String
decodeUrl(java.lang.String url)
Decodes the specified URL as per RFC 3986, i.e.static java.io.File
toFile(java.net.URL url)
Convert from aURL
to aFile
.
-
-
-
Method Detail
-
decodeUrl
static java.lang.String decodeUrl(java.lang.String url)
Decodes the specified URL as per RFC 3986, i.e. transforms percent-encoded octets to characters by decoding with the UTF-8 character set. This function is primarily intended for usage withURL
which unfortunately does not enforce proper URLs. As such, this method will leniently accept invalid characters or malformed percent-encoded octets and simply pass them literally through to the result string. Except for rare edge cases, this will make unencoded URLs pass through unaltered.- Parameters:
url
- The URL to decode, may benull
.- Returns:
- The decoded URL or
null
if the input wasnull
.
-
toFile
public static java.io.File toFile(java.net.URL url)
Convert from aURL
to aFile
.From version 1.1 this method will decode the URL. Syntax such as
file:///my%20docs/file.txt
will be correctly decoded to/my docs/file.txt
. Starting with version 1.5, this method uses UTF-8 to decode percent-encoded octets to characters. Additionally, malformed percent-encoded octets are handled leniently by passing them through literally.- Parameters:
url
- the file URL to convert,null
returnsnull
- Returns:
- the equivalent
File
object, ornull
if the URL's protocol is notfile
-
-