I am not clear in my understanding of this whole issue of "path". What I know is that path of a file means the location of a file in a computer system. But what is the path name which we give in the File constructor ? what is canonical path and absolute path ? Could somebody explain this in very simple terms or examples ?
"JavaRanch, where the deer and the Certified play" - David O'Meara
Jennifer Wallace
Ranch Hand
Joined: Nov 30, 2001
Posts: 102
posted
0
Thanks. I am able to grasp the difference between Canonical and Absolute paths. But one another doubt, "test.txt" exists in my current working directory and if I try to print the parent directory of the file, I get null. What am I missing here ? File f=new File("test.txt"); System.out.println(f.getParent{});
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
posted
0
You have to specify the entire path when you create the file object.File f=new File(path to file\"test.txt");
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley