开发者

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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜