美文网首页
Flie类笔记

Flie类笔记

作者: 扒块腹肌 | 来源:发表于2017-01-20 00:13 被阅读10次

    1.File类的三种构造方式

    创建一个新 File 实例指向给定路径名字符串表示的抽象路径名

    File(String path)
    File file = new File("D:/1.txt");
    

    根据 parent 抽象路径名和 child 路径名字符串创建一个新 File 实例

    File(File parent, String child)
    File parent = new File(D:/src);
    File file = new File(parent , "Test.java");
    

    根据 parent 路径字符串和 child 路径名字符串创建一个新 File 实例

    File(String parent, String child)
    String parent = "D:/src";
    File file = new File(parent , "Test.java");
    
    

    2.File类方法
    创建功能;

    boolean delete()  表删除
    boolean ceratNewFile() 创建指向抽象路径的空白文件
    boolean mkdir()  创建单级目录(不能创建多级!!)
    boolean mkdirs() 创建多级目录
    boolean renameTo(File dest) 剪切并重命名
    
    

    获取功能

    
    

    判断功能

    高级特性

    相关文章

      网友评论

          本文标题:Flie类笔记

          本文链接:https://www.haomeiwen.com/subject/vkkwbttx.html