本文整理汇总了Java中org.jdom.output.XMLOutputter.getFormat方法的典型用法代码示例。如果您正苦于以下问题:Java XMLOutputter.getFormat方法的具体用法?Java XMLOutputter.getFormat怎么用?Java XMLOutputter.getFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom.output.XMLOutputter
的用法示例。
在下文中一共展示了XMLOutputter.getFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeToXml
import org.jdom.output.XMLOutputter; //导入方法依赖的package包/类
/**
* Writes the JDOM document to the outputstream specified
* @param out the outputstream to which the JDOM document should be writed
* @param validate if true, validate the dom structure before writing. If there is a validation error,
* or the xsd is not in the classpath, an exception will be thrown.
* @throws ConverterException
*/
public void writeToXml(Pathway pwy, OutputStream out, boolean validate) throws ConverterException {
Document doc = createJdom(pwy);
//Validate the JDOM document
if (validate) validateDocument(doc);
// Get the XML code
XMLOutputter xmlcode = new XMLOutputter(Format.getPrettyFormat());
Format f = xmlcode.getFormat();
f.setEncoding("UTF-8");
f.setTextMode(Format.TextMode.PRESERVE);
xmlcode.setFormat(f);
try
{
//Send XML code to the outputstream
xmlcode.output(doc, out);
}
catch (IOException ie)
{
throw new ConverterException(ie);
}
}
示例2: flush
import org.jdom.output.XMLOutputter; //导入方法依赖的package包/类
public void flush() throws IOException
{
XMLOutputter xmlcode = new XMLOutputter(Format.getPrettyFormat());
Format f = xmlcode.getFormat();
f.setEncoding("ISO-8859-1");
f.setTextMode(Format.TextMode.PRESERVE);
f.setLineSeparator(System.getProperty("line.separator"));
xmlcode.setFormat(f);
//Open a filewriter
PrintWriter writer = new PrintWriter(out);
xmlcode.output(doc, writer);
out.flush();
}