Properties in java
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sudarsan_Mukundhan
Posted On:   Friday, December 20, 2002 01:46 AM

How can i use set and get of properties class??

Re: Properties in java

Posted By:   John_Ewing  
Posted On:   Friday, December 20, 2002 06:52 AM


public class AppProperties extends java.util.Properties{
private String theFileName = null;
private static KPIniFile thePropFileInstance = null;

// private constructor
private AppProperties() {
super();
this.setFileName("app.properties");
this.loadProperties();
}
// singleton
public static synchronized KPIniFile getInstance(){
if thePropFileInstance != null){
return thePropFileInstance
}
return thePropFileInstance = new KPIniFile();
}

// Here is your answer **get**
public String getCICSProgram(){
return thePropFileInstance.getProperty("CICSProgram");
}

public void loadProperties() {
try {
if (theFileName==null) throw new Exception();

java.io.InputStream inStream = ClassLoader.getSystemResourceAsStream(theFileName);
this.load(inStream);
inStream.close();
}catch (Exception e) {
System.out.println("File could not be found");
}
}

public void setFileName(String filename) {
theFileName = filename;
}

}
About | Sitemap | Contact