Thursday, July 21, 2011

Reading a property file from a web service.

Put the property file( lets say file name is myfile.properties) into //axis2/WEB-INF/classes

In java code of your web service, you can use that property file as follows:

InputStreamReader mainPropISR = new InputStreamReader(this.getClass().getResourceAsStream("/myfile.properties"));
Properties mainPropFile = new Properties();
mainPropFile.load(mainPropISR)

Please note that '/' needed before the property file name in order for axis to read it directly from the class folder. Any other path declarations will taken relative to the current java file.

No comments: