probelm in properties

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.
 
S

subi

I have to use static method as i read the returned value in a legacy
method which should take only static values.

Thanks,
Subi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top