• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
leo tien
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
leo tien
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
leo tien
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic