Class 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 by FileLocatorUtils. 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 a URL to a File.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UTF8

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

      • FileUtils

        FileUtils()
    • 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 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.
      • toFile

        public static java.io.File toFile​(java.net.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