The GetFilePath method parses a file URL and returns the
equivalent absolute Windows path. This includes support for URLs that
reference local files, mapped drives, and UNC network shares. The
returned path is normalized to remove extraneous path delimiters and
redundant components (such as . or .. directory references) and will
ensure it adheres to the standard Windows path format. The file name
returned by this method is always an absolute path.
URL encoding ensures interoperability with other platforms and
allows safe transport over networks using protocols which may not
support 8-bit characters. If the file URL contains encoded UTF-8 characters
they will be automatically decoded. If the file URL contains an
invalid UTF-8 encoding sequence, this can cause the method to fail.
This method does not require the file to exist and will not check access
permissions. It is solely concerned with converting a URL to a
Windows-compatible file path. If validation is required, it must be
performed separately after calling this method. The method will
preserve any mixed-case characters in the file path.
It is important to note that file URLs always reference absolute
paths. Some older browsers and early versions of the Java runtime
supported file URLs with relative paths by omitting the authority
portion of the URL; however, this method explicitly prohibits this
usage because relative paths may not be deterministic. The current
working directory is stored as a global value for each process, and
the use of a file URL with a relative path can potentially cause
unpredictable behavior.
The GetFileUrl method can be used to convert a Windows file
path to a standard a file URL.