package abc;import java.io.IOException;import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;public class TransXML {
private static TransXML xmlInstance;private Element ipConfig;
private TransXML(String xmlPath)
{ SAXBuilder builder=new SAXBuilder(false);
try {
Document doc=builder.build(xmlPath);
ipConfig=doc.getRootElement();
} catch (JDOMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getIpConfig(String configName)
{
return ipConfig.getChild(configName).getText();
}
public static synchronized TransXML getInstance(String xmlPath)
{
if(xmlInstance==null)
{xmlInstance=new TransXML(xmlPath);}
return xmlInstance;
}}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
IPConfig.xml
<ipconfig>
<ftpserver>192.168.1.254</ftpserver>
<ftpport>21</ftpport>
<ftpuser>zyt</ftpuser>
<ftpswd>zyt</ftpswd><filepath>/webapps/weatherreport/uploadpic/</filepath><dbfilepath>W://姣忔棩鍗瑙嗛//</dbfilepath>
</ipconfig>
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;public class TransXML {
private static TransXML xmlInstance;private Element ipConfig;
private TransXML(String xmlPath)
{ SAXBuilder builder=new SAXBuilder(false);
try {
Document doc=builder.build(xmlPath);
ipConfig=doc.getRootElement();
} catch (JDOMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getIpConfig(String configName)
{
return ipConfig.getChild(configName).getText();
}
public static synchronized TransXML getInstance(String xmlPath)
{
if(xmlInstance==null)
{xmlInstance=new TransXML(xmlPath);}
return xmlInstance;
}}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
IPConfig.xml
<ipconfig>
<ftpserver>192.168.1.254</ftpserver>
<ftpport>21</ftpport>
<ftpuser>zyt</ftpuser>
<ftpswd>zyt</ftpswd><filepath>/webapps/weatherreport/uploadpic/</filepath><dbfilepath>W://姣忔棩鍗瑙嗛//</dbfilepath>
</ipconfig>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货