📄 xmlbeanwriterimpl.java
字号:
/**
* =============================================
* Copyright 2005 TransFar
*
* Change Revision
* --------------------------------
* Date Author Remarks
* 2006-3-10 YHuang Create class com.szmx.component.xml.rw.impl.XmlBeanWriterImpl
* =============================================
*/
package com.szmx.component.xml.rw.impl;
import com.szmx.component.xml.rw.XmlBeanWriter;
import com.szmx.component.xml.rw.XmlBeanException;
import com.szmx.component.xml.rw.AbstractXmlBean;
import com.szmx.component.xml.rw.XmlBeanReader;
import com.wutka.jox.JOXBeanOutputStream;
import com.wutka.dtd.DTDParser;
import com.wutka.dtd.DTD;
import java.io.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <TODO: Write a short description on the purpose of the program>
*
* @author YHuang
* @version 1.0
* @class com.szmx.component.xml.rw.impl.XmlBeanWriterImpl
* @since 2006-3-10
*/
public class XmlBeanWriterImpl implements XmlBeanWriter {
private static Log log = LogFactory.getLog(XmlBeanReader.class);
public void writerXmlFile(String rootName,
String xmlPath,
String dtdPath,
AbstractXmlBean xmlBean) throws XmlBeanException {
FileOutputStream fileOut;
try {
fileOut = new FileOutputStream(xmlPath);
FileReader reader = new FileReader(dtdPath);
DTDParser dtdParser = new DTDParser(reader);
DTD dtd = dtdParser.parse();
reader.close();
JOXBeanOutputStream joxOut = new JOXBeanOutputStream(dtd, fileOut);
joxOut.writeObject(rootName, xmlBean);
joxOut.close();
} catch (FileNotFoundException e) {
log.error("file not found " + e.getMessage());
throw new XmlBeanException("file not found " + e.getMessage());
} catch (IOException e) {
log.error("Cant't write the file " + e.getMessage());
throw new XmlBeanException("Cant't write the file " + e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -