java elementtext_Java Element.elementTextTrim方法代码示例

  • Post author:
  • Post category:java


import org.dom4j.Element; //导入方法依赖的package包/类

/**

* 获取配置

*

* @param name

* @return

* @throws Exception

*/

public static HttpConfig getConfig(String name) throws Exception {

HttpConfig hc = CONFIG_MAP.get(name);

if (hc == null) {

SAXReader reader = new SAXReader();

File xml = new File(HTTP_CONFIG_FILE);

Document doc;

Element root;

if (xml.exists()) {

try (FileInputStream in = new FileInputStream(xml); Reader read = new InputStreamReader(in, “UTF-8”)) {

doc = reader.read(read);

root = doc.getRootElement();

List els = root.selectNodes(“/root/configs/config”);

for (Element el : els) {

String nameStr = el.attributeValue(“name”);

String encodeTy



版权声明:本文为weixin_31969199原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。