Article View: borland.public.jbuilder.java.language
Article #7419Re: Locating an INI file
From: Russell
Date: Fri, 22 Jun 2001 03:59
Date: Fri, 22 Jun 2001 03:59
52 lines
2385 bytes
2385 bytes
Hi Mio Mio ,
Your code is ok , just added your properties in the correct classpath
.
If your package is com.mio.file , put the properties in the class
folder with same directory name.
Tested your code, is ok for me.
bonjour
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:
<3B32C2A8.7D28A1DD@cesmainternational.com>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> <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-21 21:09:50 PST Message-ID: <3B32C2A8.7D28A1DD@cesmainternational.com> Date: Fri, 22 Jun 2001 11:59:36 +0800 From: Russell <weetat@cesmainternational.com> X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.13-0.13 i686) 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: 203.126.155.39 X-Trace: dnews 993182400 203.126.155.39 (21 Jun 2001 21:00:00 -0700) Lines: 52 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