• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Intelligent Current Working Directory

 
Frank Verbruggen
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.


Percieved by me as the file must be in:



Now I wonder, how to append to this user dir the filename in such a way that it will work on systems other than Windows too ?

Idea's ???
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about
 
David Abramowicz
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, path separator is what is used to separate COMPLETE paths, ';' in Windows and ':' in Unix.

What you are looking for is File.separator which is '\' in Windows and '/' in Unix.

Not exactly inuitive is it

/Dave
[ February 22, 2005: Message edited by: David Abramowicz ]
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops! I was in a hurry when I wrote that, and put the wrong constant in there! Thanks for catching that, David, and my apologies to any readers I may have confused...
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Frank Verbruggen:


Now I wonder, how to append to this user dir the filename in such a way that it will work on systems other than Windows too ?

Idea's ???


I believe if you just leave the path off, most, if not all operating systems that Java runs on will use the current working directory. At least both Unix and Windows will do this.

Windows (and DOS) has the additional property that each drive has a current directory. But if you don't specify anything it uses the drive the program was started in.
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David Abramowicz:
Actually, path separator is what is used to separate COMPLETE paths, ';' in Windows and ':' in Unix.

What you are looking for is File.separator which is '\' in Windows and '/' in Unix.

Not exactly inuitive is it

/Dave

And why should one mess with the separator, when Java can handle this trouble for us? Just use
Or (I would guess this is essentially the same; look it up if you want to be sure):


Frans.
 
joe lin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i think if we code like this:
File file = new File("suncertify.properties");
that is to say we want to find suncertify.properties
in current working directory.
 
Frank Verbruggen
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Frans Janssen:

Or (I would guess this is essentially the same; look it up if you want to be sure):


Frans.


Finally.
THAT was where I was looking for (a long time ago, that is)
Thanx ranchers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic