S
subi
Hi,
I am trying to read from a property file using the following code. I
dont get the value for "name" key. So I tried to read the number of
keys in the file, that too return 0. Could you please help me.
Code:
----------
static String rateFinder()
{
int elen=0;
Properties props=new Properties();
try
{
props.load( new FileInputStream(new File("test.properties")));
}
catch(IOException ie)
{
System.out.println("Error reading file");
}
// String key = "name";
// String val = props.getProperty(key,"notfound");
Enumeration enum = props.keys();
while(enum.hasMoreElements())
{
elen+=1;
}
return Integer.toString(elen);
}
test.properties
----------------------
name=subi
roll=101
mark1=100
*****
Both the files are in same location, indeed i do not get IOException.
It seems the method reads the file but not the contents. Pls help.
Thanks,
subi.
I am trying to read from a property file using the following code. I
dont get the value for "name" key. So I tried to read the number of
keys in the file, that too return 0. Could you please help me.
Code:
----------
static String rateFinder()
{
int elen=0;
Properties props=new Properties();
try
{
props.load( new FileInputStream(new File("test.properties")));
}
catch(IOException ie)
{
System.out.println("Error reading file");
}
// String key = "name";
// String val = props.getProperty(key,"notfound");
Enumeration enum = props.keys();
while(enum.hasMoreElements())
{
elen+=1;
}
return Integer.toString(elen);
}
test.properties
----------------------
name=subi
roll=101
mark1=100
*****
Both the files are in same location, indeed i do not get IOException.
It seems the method reads the file but not the contents. Pls help.
Thanks,
subi.