集册 Java实例教程 获取父目录的名称

获取父目录的名称

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

367
获取父目录的名称

 

import java.io.*;

 /*n o w  j a v a  . c o m 提 供*/

 

public class Main {

 

  public static void main(String[] args) {

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

     String strParentDirectory = file.getParent();

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

  }

}