-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
URI will decode entities when retrieving the path, something URL won't do. This makes a difference when the location was something like "file:/C:/Program%20Files/Jenkins/"
- Loading branch information
1 parent
bd21c0d
commit f4e33a2
Showing
1 changed file
with
10 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is wrong; never ever try to interconvert a
URI.path
withFile.path
directly. Instead useFile.<init>(URI)
which takes care of a number of issues automatically: path separator, handling of unusual characters such as#
, etc.The reverse operation is
File.toUri
. Never useFile.toURL
which is badly broken.(The only thing
File
/URI
methods do not handle quite correctly is Windows UNC paths such as\\server\share\path
, for which you need to depend on Java 7:java.nio.file
methods properly interconvertURI
andPath
even when UNC paths are involved, e.g. asfile://server/share/path
, whereasFile
/URI
conversion works withfile:////server/share/path
which does not survive a round trip throughURI.normalize
.)