import javax.swing.JOptionPane;
import org.dom4j.*;
import org.dom4j.io.SAXReader;
/**
*
* @author Cy.Co.Labs
*/
public class AppSettings {
private String appname;
////////////////////////////////////////////////
private static AppSettings appsettings;
private AppSettings() {
}
public static AppSettings getAppSettings() {
System.gc();
if (appsettings == null) {
appsettings = new AppSettings();
}
return appsettings;
}
////////////////////////////////////////////////
public setLoadAppSettings() {
b = false;
try {
SAXReader reader = new SAXReader();
Document document = reader.read(new File(Util.getUtil().getUserDirectory() + "\\appsettings.xml"));
AppSettings.getAppSettings().setAppname(document.selectSingleNode("//settings/appname").getText());
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
/**
* @return the appname
*/
public String getAppname() {
return appname;
}
/**
* @param appname the appname to set
*/
private void setAppname(String appname) {
this.appname = appname;
}
}
appsettings.xml
<?xml version = "1.0"?>
<settings>
<appname>Java Application</appname>
</settings>
No comments:
Post a Comment