file.getParent();为什么是null呢,当前目录是有父目录的
------解决方案--------------------
File file=new File(".")获取的是当前目录的相对路径,要先将其转为绝对路径,然后再获取其父目录
File file = new File(".");
System.out.println(file.getPath());
System.out.println(file.getCanonicalFile().getParent());