toURI method of File transform space character into %20
toURI method of File transform space character into %20
On windows XP with Java 6
public static void main(Str开发者_如何学Going[] args) {
File f = new File("C:\\My dir\\test.txt");
URI uri = f.toURI();
System.out.println(f.getAbsolutePath());
System.out.println(uri);
}
C:\My dir\test.txt file:/C:/My%20dir/test.txt
This is because URLs may not contains Space characters, as specified by RFC2396!
精彩评论