获取父目录的名称
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); } }