开发者

toURI method of File transform space character into %20

开发者 https://www.devze.com 2022-12-30 02:48 出处:网络
toURI method of File transform space character into %20 On windows XP with Java 6 public static void main(Str开发者_如何学Going[] args) {

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

精彩评论

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

关注公众号