Access Properties-Files

Hi,
i want to access a property-file from an adapter-class.
Now i get this file with an FileInputStream. But every time i get an FileNotFoundException although the property-file stored in cis\WEB-INF\classes or cis\PROJECTNAME\appclasses\classes.

Can anyone help me?

Thanks

…could you show some code the code? Do you load the file by classloader or by file i/o?

Bjoern

ok here is an example coding:


Properties properties = new Properties();
properties.load(new FileInputStream(“beispiel.properties”));
String sprache = properties.getProperty(“lang”);

You see i load the file by i/o. Is it possible to load the file by classloader? Can you give me an example?

thanks

J

Hi J

Hi Bjoern,
thanks. With the classloader it works fine. But how can i load the file if i store it in a directory like …\tomcat\webapps\cis\myProject\config or somewhere else in my webapp.

J

J

Hi Bjoern,
i can not find a method like … Parameters.getApplicationDirectoryName(“yourproject”) . Please can you give me a little example coding?

Thanks,
J

…sorry, the class was com.softwareag.cis.server.Params…

/**
 * Each CIS project is represented by an own directory inside the Web-
 * Application. The directory is directly located under the Web-Application directory.
 * <br><br>
 * Example: the web application may look like...:<br>
 * webAppXYZ/casabac/.... <== some casabac directories<br>
 * webAppXYZ/cisdemos/... <== the demos project<br>
 * webAppXYZ/HTMLBasedGUI/... <== the CIS-own project<br>
 * webAppXYZ/project1/... <== application project<br>
 * webAppXYZ/project2/... <== application project<br>
 * webAppXYZ/WEB-INF/...<br>
 * webAppXYZ/META-INF/...<br>
 */
public static String getApplicationDirectoryName(String application) 

…but as I said: pay attention to servlet container restrictions. We access the function “ServletContext.getRealPath(”“);” which is an optional function according to J2EE spec.

Bjoern