java.io.File类
-
API
(1)获取文件或目录的详细信息
(2)获取文件或目录的路径import java.io.File; import java.io.IOException; import org.junit.Test; public class Test3 { @Test public void test3() throws IOException { File file = new File("../../UI/UI设计class03.ppt"); // 不规范路径 System.out.println("文件的路径:" + file.getPath()); System.out.println("文件的绝对路径:" + file.getAbsolutePath()); // D:\java\text\..\..\UI\UI设计class03.ppt System.out.println("文件的规范路径:" + file.getCanonicalPath()); // D:\UI\UI设计class03.ppt } @Test public void test2() throws IOException { File file = new File("UI/UI设计class03.ppt"); System.out.println("文件的路径:" + file.getPath()); System.out.println("文件的绝对路径:" + file.getAbsolutePath()); // D:\java\text\UI\UI设计class03.ppt System.out.println("文件的规范路径:&#