可使用OutputKeys对输出进行格式化
DOMSource doms = new DOMSource( document );
File file = new File( name );
StreamResult result = new StreamResult( file );
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
Properties properties = transformer.getOutputProperties();
properties.setProperty( OutputKeys.ENCODING, "GB2312" );
properties.setProperty( OutputKeys.METHOD, "xml" );
properties.setProperty( OutputKeys.INDENT, "yes" );
transformer.setOutputProperties( properties );
transformer.transform( doms, result );
DOMSource doms = new DOMSource( document );
File file = new File( name );
StreamResult result = new StreamResult( file );
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
Properties properties = transformer.getOutputProperties();
properties.setProperty( OutputKeys.ENCODING, "GB2312" );
properties.setProperty( OutputKeys.METHOD, "xml" );
properties.setProperty( OutputKeys.INDENT, "yes" );
transformer.setOutputProperties( properties );
transformer.transform( doms, result );
解决方案 »
- 大家都用什么工作流引擎?
- 求解socket服务的空值问题
- 求用到Comparator中int compare(T o1, T o2)的例子
- Java单元测试 JUnit 4.8.1 发布
- 请问怎么在日志中打印出hql语句对应的参数啊?
- Hibernate的insert操作 有问题???
- 初遇 java.lang.UnsupportedClassVersionError: unsupported major.minor version 49.0
- 请教webwork里token-session的用法
- hibernate的问题,大家帮我看看可能是什么错误,给我定个方向!
- 在Session bean 中引用cmp中的函数
- j2ee配置的问题,,
- ejb能够保证来自不同数据库的事务的完整性吗?
我试过了,还是不行。