This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes including ini file in project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "including ini file in project" Watch "including ini file in project" New topic
Author

including ini file in project

Niels Tielenburg
Ranch Hand

Joined: Aug 19, 2009
Posts: 44
i'm trying to store some settings in an ini file but all I can manage so far is for example to read and write from an ini file from my desktop.
is it possible to include an ini file in a project and then read and write from it?
i'm using netbeans and i did manage to get an ini file in a project but i didn't manage how to read and write from it...

thanks in advance
Jeremy Wilson
Ranch Hand

Joined: Feb 18, 2003
Posts: 166
Use the properties classes and this will allow you to load from a file url or from the classpath.


Jeremy Wilson
Niels Tielenburg
Ranch Hand

Joined: Aug 19, 2009
Posts: 44
i'm trying this:

but I think it can't find Inloggegevens.ini because it gives an null pointer exception, but the Inloggegevens.ini file is deffinitly in the project
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8915
    
    8

Niels Tielenburg wrote:but the Inloggegevens.ini file is deffinitly in the project


Is the file in the classpath? ClassLoader.getSystemResource() is going to look in the classpath for the file, so if it is not accessible, you'll get a null from that call.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Niels Tielenburg
Ranch Hand

Joined: Aug 19, 2009
Posts: 44
the file is only in the project so I assume it doesn't automatically put it in the classpath...
 
GeeCON Prague 2014
 
subject: including ini file in project