我用public static boolean doc2XmlFile(Document document,String filename){
boolean flag = true;
try
{
/** 将document中的内容写入文件中 */
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
/** 编码 */
//transformer.setOutputProperty(OutputKeys.ENCODING, "GB2312");
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(new File(filename));
transformer.transform(source, result);
}catch(Exception ex)
{
flag = false;
ex.printStackTrace();
}
return flag;
}
方法把修改后的xml写进去,不知道怎么取相对路径。。
boolean flag = true;
try
{
/** 将document中的内容写入文件中 */
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
/** 编码 */
//transformer.setOutputProperty(OutputKeys.ENCODING, "GB2312");
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(new File(filename));
transformer.transform(source, result);
}catch(Exception ex)
{
flag = false;
ex.printStackTrace();
}
return flag;
}
方法把修改后的xml写进去,不知道怎么取相对路径。。
解决方案 »
- Hibernate 4的问题。。
- 【怎样你懂的网站某个目录下的所有图片】!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- js动态的添加一行的数据怎么取值
- 求助java与C的socket通信问题,中文编码
- struts2的autocompleter标签的中文问题
- 学了j2se想进一步学j2ee,急盼各位高手给点指导,推荐一本读物
- 用Struts遇到的问题
- Spring的XML配置文件中的bean的子元素lookup-method的作用是什么
- 紧急求助!为什么在这个含有java applet的网页中无法显示图象?
- 自己手工写了个Hello的ejb,但是jboss在启动时报HelloHome interface 找不到!!
- ssh整合,怎么用log4j替换slf4j
- 异常:Width (-1) and height (-1) cannot be <= 0
System.out.println(FilePath.class.getResource("/"));