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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "getCanonical, Absolute, Path in File" Watch "getCanonical, Absolute, Path in File" New topic

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)
}catch(IOException e){ System.out.println(e); }

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.
It is sorta covered in the JavaRanch Style Guide.
subject: getCanonical, Absolute, Path in File
Similar Threads
File pathname etc...
file path etc...
whether getabsolutepath() and getcanonicalpath() are in scjp exam
IO question
I/O problem from Amit poddar's test