Tuesday, February 10, 2009

Creating and importing properties into java file

step 1)

create a property file with name Conn.Properties having example property
bvmc.LoginURL=manish
bvdb.url = jdbc:oracle:thin:



step 2)
write the following java code

private static final Properties CONNPRP = new Properties();

static {

try {

FileInputStream fileInputStream = new FileInputStream(
"config/Conn.Properties");
CONNPRP.load(fileInputStream);

} catch (Exception e)
{
throw new RuntimeException(e);
}
}


String loginURL = CONNPRP.getProperty("bvmc.LoginURL");

System.out.println("loginURL :::::: " + loginURL);

No comments:

Post a Comment