The following sample code demostrates the problem of Path.toUri(). It encodes umlaut incorrectly as 117,776.
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
public class Test {
public static void main(String[] args) throws MalformedURLException, IOException {
final File f = new File ("Frühling").getCanonicalFile(); //NOI18N
f.mkdir();
final String io = f.toURI().toURL().toString();
final String nio = f.toPath().toUri().toURL().toString();
final boolean res = io.equals(nio);
System.out.println(res);
System.out.println(io);
System.out.println(nio);
}
}
On Ubuntu with JDK 8 the same problem as on Mac, seems a problem in UNIX implementation of NIO FileSystem.
Related NetBeans bug:
https://netbeans.org/bugzilla/show_bug.cgi?id=246438
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
public class Test {
public static void main(String[] args) throws MalformedURLException, IOException {
final File f = new File ("Frühling").getCanonicalFile(); //NOI18N
f.mkdir();
final String io = f.toURI().toURL().toString();
final String nio = f.toPath().toUri().toURL().toString();
final boolean res = io.equals(nio);
System.out.println(res);
System.out.println(io);
System.out.println(nio);
}
}
On Ubuntu with JDK 8 the same problem as on Mac, seems a problem in UNIX implementation of NIO FileSystem.
Related NetBeans bug:
https://netbeans.org/bugzilla/show_bug.cgi?id=246438