Class FileUtils

java.lang.Object
org.apache.commons.configuration2.io.FileUtils

final class FileUtils extends 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 by FileLocatorUtils. The copied constants and methods are literally copied.
See CONFIGURATION-521 for a discussion.
  • Field Details

    • UTF8

      private static final Charset UTF8
      The UTF-8 character set, used to decode octets in URLs.
  • Constructor Details

    • FileUtils

      FileUtils()
  • Method Details

    • toFile

      public static File toFile(URL url)
      Convert from a URL to a File.

      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 returns null
      Returns:
      the equivalent File object, or null if the URL's protocol is not file
    • decodeUrl

      static String decodeUrl(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 with URL 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 be null.
      Returns:
      The decoded URL or null if the input was null.