Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Oscar Montgomery   on Oct 09 In Java Category.

  
Question Answered By: Garai Chalthoum    on Oct 09

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

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Report of Daffodi DB Or get search suggestion and latest updates.


Tagged: