Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes how can I use relative pathname?????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "how can I use relative pathname??????" Watch "how can I use relative pathname??????" New topic
Author

how can I use relative pathname??????

leo tien
Greenhorn

Joined: Nov 04, 2002
Posts: 11
I have one trouble in file path...the java API said: "A pathname, whether abstract or in string form, may be either absolute or relative....."but how can I use relative path???
please help me!!!
thanks before..
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Lets say you have a directory path of c:\mydir\src\com\company\gui and in that directory you have a file called filename.ext and you want to retrieve that file and you are in the directory c:\mydir\src, then the relative path is "com\company\gui\filename.ext"
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
leo tien
Greenhorn

Joined: Nov 04, 2002
Posts: 11
thanx Mark.
i see, but when the file doesn't exist, it created by the program at runtime..the file can be created in relative path???
Rich Raposa
Ranch Hand

Joined: Dec 06, 2001
Posts: 46
Sure. I use relative path all the time. It makes your code portable, and it allows you to add the file to a JAR, where only relative path makes sense.


Rich Raposa<br /><a href="http://www.javalicense.com" target="_blank" rel="nofollow">http://www.javalicense.com</a><br />Buy Java courseware -> get a free XBox!
leo tien
Greenhorn

Joined: Nov 04, 2002
Posts: 11
Oh,my dear Rich..
I'm a fresh ,,,,can you say the method more detailed?? thanx a lot !
[ January 20, 2003: Message edited by: leo tien ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how can I use relative pathname??????
 
Similar Threads
Dispatcher Relative Path
unable to extract war file after restart of tomcat
RequestDispatcher of HttpServletRequest
How to understant "pathconvert"?
RequestDispatcher