This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getCanonical, Absolute, Path in File

 
Ayman Jaffar
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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); }
}
}

 
Rong Chen
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"..\\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
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You bet it helps. Thanks alot Rong Chen.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic