toURI方法将文件转换空格字符转换为%20
在带有Java 6的Windows XP上
public static void main(String [] 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 文件:/ C:/My%20dir/test.txt