/** |
* 获取文件路径,父目录 |
*/ |
private static void method_04() { |
File f = new File( "c:\\test.java" ); |
System.out.println(f.getAbsolutePath()); |
System.out.println(f.getParent()); // 该方法返回的是绝对路径中的父目录。如果获取的是相对路径,返回null。 |
// 如果相对路径中有上一层目录该目录就是返回结果 |
File f2 = new File( "c:\\test2.java" ); |
System.out.println( "rename" + f.renameTo(f2)); |
} |