public static void main(String[] args) {
String baseFilePath = "D:\\tmp\\testFolder\\folder.txt";
File file = new File(baseFilePath);
file.setWritable(true, false); //设置写权限,windows下不用此语句
System.out.println(file.getParentFile().getName()); //testFolder
System.out.println(file.getParent()); //D:\tmp\testFolder
//创建baseFilePath文件所在的所有文件夹,使用file.getParentFile().mkdirs()
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
}