The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2000



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


re:Reading INI file into the application

Posted by Erez Katz on April 18, 2000 at 9:44 AM

first, just to make sure, you have the class java.util.Properties
which parsers INI file to hashtable, check it out.

also check

for / or \ there is the property file.separator
in the same manner you can get the user account name, user home directory and User's current working directory
this answers most of your question.

anout finding files in the classpath ... i have to think this should work :
Properties p = new Properties();

...Rickard ´┐Żberg deserves the credit for this technique
hope it helps,

Erez Katz

> Hi,

> I have an application which reads in different properties from an INI file. However when I move the application to another platform, the directory name for the INI file needs to be changed.

> For example, in Windows I would have

> RandomAccessFile raf = new RandomAccessFile("c:\app\hello.ini", "r");

> and on Unix it will become

> RandomAccessFile raf = new RandomAccessFile("/usr/local/app/hello.ini", "r");

> It is troublesome to change the code to reflect the directory change. Is there a way to put the file in the CLASSPATH and load it?

> Thanks for your help!


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us