Created File Has No Parent?
directory, file, java, nullpointerexception, parent
Solution
You need a file with a path for that, try getAbsoluteFile.
File pDir = temp.getAbsoluteFile().getParentFile();
Problem
In a java program, I create a file with ``` File temp = new File("temp"); temp.createNewFile(); ``` Then for some reason when I write ``` File pDir = temp.getParentFile(); ``` and pDir is null. I actually want to write ``` File pDir = temp.getParentFile().getParentFile(); ``` but that throws a null pointer exception.