谢谢,我试一试:import com.sun.star.io.IOException;
public class ConfigEnv {
private String envDsIp;
private int envDsPort;
private int envServerId;
private String envOfficeHome;
private int envConvertImpPort;
private static class ConfigEnvHolder {
private static final ConfigEnv INSTANCE = new ConfigEnv();
}
public int GetConvertImpPort(){
return this.envConvertImpPort;
}
public String GetDsIp(){
return this.envDsIp;
}
public int GetDsPort(){
return this.envDsPort;
}
public int GetServerId(){
return this.envServerId;
}
public String GetOfficeHome(){
return this.envOfficeHome;
}
public void SetConvertImpPort(int port){
this.envConvertImpPort = port;
}
public void SetServerId(int id){
this.envServerId = id;
}
private ConfigEnv (){
IniReader iniReader = null;
try {
iniReader = new IniReader("./fileconver_config.ini");
} catch (IOException e){
System.out.println("ioexception 1.");
e.printStackTrace();
return;
} catch (java.io.IOException e) {
// TODO Auto-generated catch block
System.out.println("ioexception 2.");
e.printStackTrace();
return;
}
//String str = iniReader.getValue("config", "ConvertImpPort");
//this.envConvertImpPort = Integer.parseInt(str);
this.envOfficeHome = iniReader.getValue("config", "OFFICE_HOME");
this.envDsIp = iniReader.getValue("config", "IP");
this.envDsPort = Integer.parseInt(iniReader.getValue("config", "Port"));
//this.envServerId = Integer.parseInt(iniReader.getValue("config", "ID"));
}
public static final ConfigEnv getInstance() {
return ConfigEnvHolder.INSTANCE;
}
}
|