I am load the properties file and get the value from that file but when i using "Properties" class and getProperty(key) method, it was return null value.
code:
public class LoadPropertiesFile {
public static String getProperty (String key, String filePath) {
Properties properties = new Properties();
InputStream inputStream = null;
String value = null;
try {
String appHome = ConfigUtil.getApplicationHome() + filePath;
inputStream = new FileInputStream(appHome);
//load a properties file
properties.load(inputStream);
//get the property value
System.out.println(properties.getProperty("7")); //print **Unlock**
System.err.println(key); //print **7**
System.out.println(value); //print **null**
value = properties.getProperty(key);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch(IOException e) {
e.printStackTrace();
}
}
}
return value;
}
}
Output:
Unlock
7
null
Property File:
2=Interactive
3=Network
4=Batch
5=Service
7=Unlock
8=Network Cleartext
10=Remote Desktop
11=Logon with cached credentials
call method:
logonType = new LoadPropertiesFile().getProperty("7", "path");
When i call that method it will return null value only. please help me guys.
to do?"
– user253751 Aug 01 '14 at 12:52