written a class which reads a .properties file and the
class should be a singleton. i dont know how to check the wether the
class is a singleton or not, can any one check the file and let me
know wether the written class is a signleton or not.
I appreciate ur Help.
Here the java file is, followed by .properties file
import java.io.FileInputStream;
import java.util.Properties;
import java.util.*;
public class PropertiesTest {
private PropertiesTest() {}
private static PropertiesTest MySingleTon = null;
public static PropertiesTest getInstance()
{
if ( MySingleTon == null ) {
MySingleTon = new PropertiesTest();
}
return MySingleTon;
}
static{
try{
FileInputStream propFile = new FileInputStream
("c:\\route.properties");
Properties p = new Properties();
p.load(propFile);
Enumeration keys = p.propertyNames();
while (keys.hasMoreElements())
{
String key = (String)keys.nextElement();
String value = p.getProperty(key);
System.out.println( " the property value of " + key + " and
value is " + value);
}//end of while
}catch(Exception e){e.getMessage();}
}
}
hostname=localhost
portnumber=12345
servername=asddggf
etdname=etdFilein
eventname=et_FileIn