Article View: borland.public.jbuilder.java.language
Article #7417Re: Locating an INI file
From: Mio Nino Marquez
Date: Fri, 22 Jun 2001 03:10
Date: Fri, 22 Jun 2001 03:10
38 lines
1975 bytes
1975 bytes
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:
<3b32b664$2_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<3b317205_1@dnews> <3B321DFB.FDB5BBC2@formlessvoid.com>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-21 20:08:52 PST From: "Mio Nino Marquez" <mionino[nospam]@apsilontech.com> Newsgroups: borland.public.jbuilder.java.language References: <3b317205_1@dnews> <3B321DFB.FDB5BBC2@formlessvoid.com> Subject: Re: Locating an INI file Date: Fri, 22 Jun 2001 11:10:30 +0800 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 165.21.114.96 Message-ID: <3b32b664$2_1@dnews> X-Trace: dnews 993179236 165.21.114.96 (21 Jun 2001 20:07:16 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews