Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Load Resource Bundle at runtime

  Asked By: Juana    Date: Feb 11    Category: Java    Views: 1526
  

I need to create and load a properties (resource bundle) file at
runtime. I know that there is a ClassLoader class but I cannot seem to
make it work properly.
Any ideas ?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Omar Walker     Answered On: Feb 11

create a propertyhandler class

// use this method for loading the file  and use the refernce of class  in u r
code and call the constants from u r properties  file
public int loadPropertyFile(String propFileName)
{
String sMethodName = sClassName+".loadPropertyFile";
int rc = -1;
try {
FileInputStream propIS = new FileInputStream( propFileName );
this.load(propIS);
propIS.close();
rc = 0;
} catch (Exception e) {
rc = -1;
//if (debug) System.out.println ("!!!! ERROR: "+sMethodName+" property
file '"+propFileName+"' not found !!");
System.out.println ("!!!! ERROR: "+sMethodName+" property file
'"+propFileName+"' not found !!");
}
return rc;
}

 
Didn't find what you were looking for? Find more on Load Resource Bundle at runtime Or get search suggestion and latest updates.




Tagged: