Java生成XML时,换行和缩进
2015-12-17 14:57
751 查看
<pre name="code" class="java"> TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); Source xmlSource = new DOMSource(document); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Result transformResult = new StreamResult(baos); transformer.transform(xmlSource, transformResult);
相关文章推荐
- window7下 破解My eclipse 10
- java按文件大小、名称、日期排序方法
- Java并发编程:volatile关键字解析
- 【转载】javaAgent 参数
- java中poi进行execl导出
- 对于java中作用域
- 为什么EL表达式能访问struts2的值栈
- Java基础学习总结(39)——Log4j 1使用教程
- Java基础学习总结(39)——Log4j 1使用教程
- Java基础学习总结(39)——Log4j 1使用教程
- 非web环境,maven+spring+mybatis配置,备忘
- java web项目DAO层通用接口BaseDao与实现类BaseDaoImpl
- Java Netty简介
- spring三层示例controller层,service层示例,dao层示例
- Spring MVC学习总结(2)——Spring MVC常用注解说明
- Spring MVC学习总结(2)——Spring MVC常用注解说明
- Spring MVC学习总结(2)——Spring MVC常用注解说明
- Spring MVC常用注解说明
- Java多线程实现异步调用
- struts.xml中result的学习