i've been trying off and on for some months now to make use of the underlying java resourceBundle classes to handle rb files but haven't had much success (mainly because java expects rb files in class paths and thats not something i can live with on some projects nor could i find a simple workaround). while staring at some limestone rocks on saturday i had a micro epiphany about java.util.PropertyResourceBundle class. this class handles rb files from an input stream (ie you can pump in the rb file content from anyplace on the server). badda bing (i actually thought that at the time ;-) here's some test code i whipped up:
<cfscript>
thisDir= GetDirectoryFromPath(expandpath("*.*"));
rbFile=thisDir & "test_th_TH.properties";
rb = createObject("java", "java.util.PropertyResourceBundle");
fis = CreateObject("java", "java.io.FileInputStream");
fis.init(rbFile);
rb.init(fis);
keys=rb.getKeys();
writeoutput("resourceBundle=#rbFile#<br>");
while (keys.hasMoreElements()) {
thisKEY=keys.nextElement();
thisMSG=rb.handleGetObjectthisKey);
writeoutput("#thisKEY#=#thisMSG#<br>");
}
</cfscript>
as you can see its quite simple, so simple i built it into a javaRB.cfc. you can see it in action here.
limestone rocks, who would have thought?
There are no comments for this entry.

