This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of React Cookbook: Recipes for Mastering the React Framework and have David Griffiths & Dawn Griffiths on-line!
See this thread for details.
Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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: 805
  • 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: 805
  • 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
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic