🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7428

Re: Locating an INI file

#7428
From: Rich Wilkman
Date: Fri, 22 Jun 2001 17:25
48 lines
2264 bytes
Mio:

As Russell pointed out, just move your .properties file.  However your
method is a bit different than the one I suggested.  Mine binds the
.property file a little more tightly to the object.

-Rich

Mio Nino Marquez wrote:
> 
> ich,
> 
> I guess I'm missing something coz I couldn't get the following code to work.
> 
> package testproject;
> <import stuff here>
> public class loadPropertyFile {
>  public loadPropertyFile() {
>   try {
>    Properties props = new Properties();
>    URL u = ClassLoader.getSystemClassLoader().getResource("foo.properties");
>    if (u != null) {
>     props.load(u.openStream());
>     System.out.println("Properties file loaded!");
>    }
>   }
>   catch (Exception ex) {
>   }
>  }
>  public static void main(String[] args) {
>   loadPropertyFile x = new loadPropertyFile();
>  }
> }
> 
> The testproject folder is in e:\MyJava\TestProject.
> The source codes are in e:\MyJava\TestProject\src\testproject
> The output class files are in e:\MyJava\TestProject\classes\testproject
> 
> I've tried placing the foo.properties file in
> e:\MyJava\TestProject\src\testproject and in
> e:\MyJava\TestProject\classes\testproject, but I still couldn't manage to
> read the file (u object always returns null)
> 
> Please tell me what's wrong with the above.
> 
> Thanks.
> 
> Mio Nino Marquez
Technical Details
Message-ID: <3B337F75.584D4CC@formlessvoid.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3b317205_1@dnews> <3B321DFB.FDB5BBC2@formlessvoid.com> <3b32b664$2_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,52be12fbe909d3e9
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-22 10:37:05 PST
Message-ID: <3B337F75.584D4CC@formlessvoid.com>
Date: Fri, 22 Jun 2001 10:25:09 -0700
From: Rich Wilkman <richw@formlessvoid.com>
X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Locating an INI file
References: <3b317205_1@dnews> <3B321DFB.FDB5BBC2@formlessvoid.com> <3b32b664$2_1@dnews>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 208.236.69.60
X-Trace: dnews 993230708 208.236.69.60 (22 Jun 2001 10:25:08 -0700)
Lines: 48
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews