• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Intelligent Current Working Directory

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ???
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic