• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

properties file

 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys:
Trying to access my properties file from my .java
Gave the command below
Properties p = new Properties();

try{
p.load(new FileInputStream("/com/learnApp/learnTap/pages/home/Home.properties"));
}
catch(FileNotFoundException fne)
{
System.out.println("File Not Found Exception.");
fne.printStackTrace();
}
catch(IOException ioe)
{
System.out.println("IO Exception.");
ioe.printStackTrace();
}
Got an error that the path could not be found.
Please; if any one can help me to resolve this.
Actually the properties file is located at the directory where I point to in my code. I also tried so many variation of path for ("/com/learnApp/learnTap/pages/home/Home.properties") without succes.

Thanks,
Anselm.
[ May 19, 2005: Message edited by: Anselm Paulinus ]
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody help me out here?
Can Greg or anyone help?
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try method getRessourceAsStream in java.lang.Class.
yourObject.getClass().getRessourceAsStream("filePath");
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Axel Janssen:

I had to use ResourceBundle to access the file in order to get the key value pair I was looking for; probably a little more codes than Properties file but it still did the job for me.

Thanks once again for assisting.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic