How To Load The Property File In Java

Posted on by
How To Load The Property File In Java Average ratng: 5,6/10 1984votes
Load Property File In Java

Rankem Coa Download. Description: This example shows how to load properties file from a local file system. Here we are using FileInputStream to load the properties file. Load a properties file from classpath. Load a properties file config. Setup.exe E173. properties from project classpath, and retrieved the property value. P.S Assume properties file “config. Xena Warrior Princess .exe more. properties” is in your project classpath root folder.

When loading the Properties from a Class in the package com.al.common.email.templates you can use Properties prop = new Properties(); InputStream in = getClass().getResourceAsStream('foo.properties'); prop.load(in); in.close(); (Add all the necessary exception handling). If your class is not in that package, you need to aquire the InputStream slightly differently: InputStream in = getClass().getResourceAsStream('/com/al/common/email/templates/foo.properties'); Relative paths (those without a leading '/') in getResource()/ getResourceAsStream() mean that the resource will be searched relative to the directory which represents the package the class is in.

Comments are closed.