本文整理匯總了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();
}