public class demo02 {
public static void main(String[] args) {
String parentPath="E:/others";
String name="w.png";
//以相对路径构建
File src=new File(parentPath, name);//以相对路径构建
src=new File(new File(parentPath), name);
System.out.println(src.getName());
System.out.println(src.getPath());
//绝对路径
src=new File("E:/others/w.png");
//没有指定盘符:以user.dir构建
src=new File("test.txt");
src=new File(".");//以当前路径
System.out.println(src.getAbsolutePath());
}
}
[IO]——File对象
最新推荐文章于 2022-11-22 00:11:37 发布