Wednesday, May 13, 2009

JAVA: Reading Properties File

public static String getProperty(String filePath,String property) throws java.io.IOException
{
String value="";
java.io.File f = new java.io.File(filePath);
if(f.exists()){
java.util.Properties pro = new java.util.Properties();
java.io.FileInputStream in = new java.io.FileInputStream(f);
pro.load(in);

value =pro.getProperty(property);

}
else
{
value="";
}
return value;
}

No comments: