Based on the hint and link provided in the answer of Simone Jannis, this is my hack to fix this.
I am testing uri.getAuthority () because the UNC path will report privileges. This is a mistake - so I rely on the existence of an error that is evil, but it seems like it will stay forever (since Java 7 solves the problem in java.nio.Paths).
Note. In my context, I get absolute paths. I tested this on Windows and OS X.
(Still looking for a better way to do this)
package com.christianfries.test; import java.io.File; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; public class UNCPathTest { public static void main(String[] args) throws MalformedURLException, URISyntaxException { UNCPathTest upt = new UNCPathTest(); upt.testURL("file://server/dir/file.txt");
Christian Fries Aug 30 '13 at 8:50 2013-08-30 08:50
source share