예제 #1
0
 /**
  * 设置配置项的值并保存
  *
  * @param fileName 文件名
  * @param path 路径
  * @param value 值
  * @throws Exception 异常
  */
 public static void setStringValue(String fileName, String path, String value) throws Exception {
   Element root = getRoot(fileName);
   if (root == null) {
     return;
   }
   Element node = (Element) root.selectSingleNode(path);
   if (node == null) {
     return;
   }
   node.setText(value);
   writeBack(fileName);
 }
예제 #2
0
 /**
  * 设置配置项的值并保存
  *
  * @param fileName 文件名
  * @param pre 参数
  * @param nameSpace 空间
  * @param path 路径
  * @param attr 属性
  * @param value 值
  * @throws Exception 异常
  */
 public static void setStringValue(
     String fileName, String pre, String nameSpace, String path, String attr, String value)
     throws Exception {
   Element root = getRoot(fileName);
   if (root == null) {
     return;
   }
   root.addNamespace(pre, nameSpace);
   Element node = (Element) root.selectSingleNode(path);
   if (node == null) {
     return;
   }
   node.addAttribute(attr, value);
   writeBack(fileName);
 }