I tried the code: String name = (new File (�file.txt�)).getParent(); and the output was �null�. Does getParent work on absolute paths only? Note please that �file.txt� did exist on the current directory.
No. If you create a File object with a relative pathname (for example by just specifying the filename and not the directory) then Java assumes that you mean a file in the current working directory. A file always has an absolute path, even if you don't specify it explicitly.