File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes what is java's equivalent to c/c++ string table resource files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "what is java Watch "what is java New topic
Author

what is java's equivalent to c/c++ string table resource files

Nathan Tran
Greenhorn

Joined: Jun 05, 2001
Posts: 7
Can anyone tell me what is java's equivalent to c/c++ string table resource files? I want to write a logfile scanner that takes it's input parameter from either a string file/table. The scanner reads an error string from a file/table, searches through the log file for that error string; if not found, it reads the next error string from the file/table, searches for that string in the file; etc., until there's no more error strings to read from the file/table.
I heard a properties file could be a potential candidate. Can anyone provide me an example of what a java properties file of this type would look like. I'm interested in generating something like...
error1=Error:*failed.
error2=Error: Unable to*
error3=The system cannot find the file specified.
error4=Compile Error in File
Thanks so much in advance!!!
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by Nathan Tran:
Can anyone tell me what is java's equivalent to c/c++ string table resource files? I want to write a logfile scanner that takes it's input parameter from either a string file/table. The scanner reads an error string from a file/table, searches through the log file for that error string; if not found, it reads the next error string from the file/table, searches for that string in the file; etc., until there's no more error strings to read from the file/table.
I heard a properties file could be a potential candidate. Can anyone provide me an example of what a java properties file of this type would look like. I'm interested in generating something like...
error1=Error:*failed.
error2=Error: Unable to*
error3=The system cannot find the file specified.
error4=Compile Error in File
Thanks so much in advance!!!

I guess you have answered your question.
Yeah properties files can be used and it will have exactly the same kind of entries you have.
<key1>=<value>
<key2>=<value>
Since properties inherit from hashtable, u can get the enumeration of the keys from the properties file.
Properties p = new Properties();
p.load(new FileInputStream(<something>.properties);
Enumeration e = p.keys();
///go ahead.
karthik.
Nathan Tran
Greenhorn

Joined: Jun 05, 2001
Posts: 7
Thanks for the quick response Karthik.
Out of curiousity, would a properties file be the best way to implement an error string table?
Thanks again. :-)
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by Nathan Tran:
Thanks for the quick response Karthik.
Out of curiousity, would a properties file be the best way to implement an error string table?
Thanks again. :-)

Infact we do it the same way @ our place to get the error codes out. So what we have is a MessageHandler class which reads in all the properties in the beginning when the server starts up.
Then we do
MessageHandler.getMessage(<key>);
We do this kind of a thing to store sql queries as well, so that there's a centralised place of storing the queries.
It looks decent to me :-)
karthik.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is java's equivalent to c/c++ string table resource files