集册 Java实例教程 获取父目录作为文件对象

获取父目录作为文件对象

欢马劈雪     最近更新时间:2020-01-02 10:19:05

370
获取父目录作为文件对象

 

import java.io.*;
/*来自 
 时 代 J a v a - nowjava.com*/

 

public class Main {

 

  public static void main(String[] args) {

    File file = new File("C://Folder/demo.txt");

    File fileParent = file.getParentFile();

    System.out.println("Parent directory is : " + fileParent.getPath());

  }

}