aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes getCanonical, Absolute, Path in File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "getCanonical, Absolute, Path in File" Watch "getCanonical, Absolute, Path in File" New topic
Author

getCanonical, Absolute, Path in File

Ayman Jaffar
Ranch Hand

Joined: Sep 06, 2000
Posts: 57
Q: Consider a directory structure like this (NT or 95)
c:\JAVA\12345.msg --FILE
c:\JAVA\dir1\IO.class -- IO.class is under dir1
I don't understand the results of this code...And what does "..\\12345.msg" mean ?
import java.io.*;
public class IO {
public static void main(String args[]) {
File f = new File("..\\12345.msg"); //line (1)
try{
System.out.println(f.getCanonicalPath());
System.out.println(f.getAbsolutePath());
System.out.println(f.path());
}catch(IOException e){ System.out.println(e); }
}
}


america
Rong Chen
Ranch Hand

Joined: Aug 07, 2000
Posts: 30
"..\\12345.msg" means the file with name 12345.msg located on the parent direcotry of current directory. Here "\\" is necessary to express "\" in a string.
Does it help?
Ayman Jaffar
Ranch Hand

Joined: Sep 06, 2000
Posts: 57
You bet it helps. Thanks alot Rong Chen.
 
wood burning stoves
 
subject: getCanonical, Absolute, Path in File