import java.io.File;
public class DirSize {
public static void main(String[] args) {
File dir = new File("/home/huanyu/Desktop");
String parentPath =dir.getParent();
System.out.println("该目录的上级目录为:"+parentPath);
}
}
![img_3d0d09103a9b26e9f29b3e0206171d79.png](https://i-blog.csdnimg.cn/blog_migrate/baea48c5d053374e9c87736cfd07e967.png)
import java.io.File;
public class DirSize {
public static void main(String[] args) {
File dir = new File("/home/huanyu/Desktop");
String parentPath =dir.getParent();
System.out.println("该目录的上级目录为:"+parentPath);
}
}