[IO]——File对象

来源:互联网 发布:广电总局的网络 编辑:程序博客网 时间:2024/04/27 20:19
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());}}

0 0
原创粉丝点击