qq_36680552
Null________
2017-10-25 07:18

java 用sax生成xml文件怎么释放

1
  • java
  • xml
        File file = new File(“g:/123.xml”);
        try {
            SAXTransformerFactory stf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
            TransformerHandler handler = stf.newTransformerHandler();
            Transformer tf = handler.getTransformer();
            tf.setOutputProperty(OutputKeys.INDENT, "yes");// 标签自动换行
            tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");// 编码格式
            StreamResult result = new StreamResult(file);// 创建Result对象
            handler.setResult(result);// 关联
            handler.startDocument();
            handler.startElement("", "", "tb_students", null);// 根节点标签
                .
                .
                .
                handler.endElement("", "", "tb_students");// 结束根节点标签
            handler.endDocument();
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答