Java 文件路径/URL/URI操作汇总
路径操作汇总
URI/相对/拒绝/路径/文件
package cn.netkiller.test;
import java.io.File;
public class Test {
public Test() {
}
public static void main(String[] args) throws Exception {
String path = "src/java/resources";
File file = new File(path);
System.out.println("toURI: " + file.toURI());
System.out.println("toURL: " + file.toURI().toURL());
System.out.println("getParent: " + file.getParent());
System.out.println("getParentFile: " + file.getParentFile());
System.out.println("getAbsolutePath: " + file.getAbsolutePath());
System.out.println("getAbsoluteFile: " + file.getAbsoluteFile());
System.out.println("getCanonicalPath: " + file.getCanonicalPath());
System.out.println("getCanonicalFile: " + file.getCanonicalFile());
System.out.println("getPath: " + file.getPath());
System.out.println("getName: " + file.getName());
System.out.println("getFreeSpace: