本文整理了Java中org.dom4j.io.OutputFormat.createPrettyPrint()
方法的一些代码示例,展示了OutputFormat.createPrettyPrint()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat.createPrettyPrint()
方法的具体详情如下:
包路径:org.dom4j.io.OutputFormat
类名称:OutputFormat
方法名:createPrettyPrint
[英]A static helper method to create the default pretty printing format. This format consists of an indent of 2 spaces, newlines after each element and all other whitespace trimmed, and XMTML is false.
[中]创建默认打印格式的静态助手方法。这种格式由两个空格的缩进、每个元素后面的换行以及所有其他经过修剪的空格组成,XMTML为false。
代码示例来源:origin: spotbugs/spotbugs
private void writeXML(Writer out, Project project) throws IOException {
Document document = endDocument(project);
XMLWriter writer = new XMLWriter(out, OutputFormat.createPrettyPrint());
writer.write(document);
}
代码示例来源:origin: ronmamo/reflections
public String toString(final Reflections reflections) {
Document document = createDocument(reflections);
try {
StringWriter writer = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(writer, OutputFormat.createPrettyPrint());
xmlWriter.write(document);
xmlWriter.close();
return writer.toString();
} catch (IOException e) {
throw new RuntimeException();
}
}
代码示例来源:origin: org.reflections/reflections
public String toString(final Reflections reflections) {
Document document = createDocument(reflections);
try {
StringWriter writer = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(writer, OutputFormat.createPrettyPrint());
xmlWriter.write(document);
xmlWriter.close();
return writer.toString();
} catch (IOException e) {
throw new RuntimeException();
}
}
代码示例来源:origin: ronmamo/reflections
public File save(final Reflections reflections, final String filename) {
File file = Utils.prepareFile(filename);
try {
Document document = createDocument(reflections);
XMLWriter xmlWriter = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
xmlWriter.write(document);
xmlWriter.close();
} catch (IOException e) {
throw new ReflectionsException("could not save to file " + filename, e);
} catch (Throwable e) {
throw new RuntimeException("Could not save to file " + filename + ". Make sure relevant dependencies exist on classpath.", e);
}
return file;
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* @since 1.4
*/
public Dom4JDriver(NameCoder nameCoder) {
this(new DocumentFactory(), OutputFormat.createPrettyPrint(), nameCoder);
outputFormat.setTrimText(false);
}
代码示例来源:origin: org.reflections/reflections
public File save(final Reflections reflections, final String filename) {
File file = Utils.prepareFile(filename);
try {
Document document = createDocument(reflections);
XMLWriter xmlWriter = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
xmlWriter.write(document);
xmlWriter.close();
} catch (IOException e) {
throw new ReflectionsException("could not save to file " + filename, e);
} catch (Throwable e) {
throw new RuntimeException("Could not save to file " + filename + ". Make sure relevant dependencies exist on classpath.", e);
}
return file;
}
代码示例来源:origin: igniterealtime/Openfire
OutputFormat prettyPrinter = OutputFormat.createPrettyPrint();
XMLWriter xmlWriter = new XMLWriter(writer, prettyPrinter);
xmlWriter.write(document);
代码示例来源:origin: spotbugs/spotbugs
@SuppressFBWarnings("DM_EXIT")
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: " + AddMessages.class.getName() + " <input collection> <output collection>");
System.exit(1);
}
// Load plugins, in order to get message files
DetectorFactoryCollection.instance();
String inputFile = args[0];
String outputFile = args[1];
Project project = new Project();
SortedBugCollection inputCollection = new SortedBugCollection(project);
inputCollection.readXML(inputFile);
Document document = inputCollection.toDocument();
AddMessages addMessages = new AddMessages(inputCollection, document);
addMessages.execute();
XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(outputFile)),
OutputFormat.createPrettyPrint());
writer.write(document);
writer.close();
}
}
代码示例来源:origin: caoxinyu/RedisClient
doc = reader.read(in);
OutputFormat formater = OutputFormat.createPrettyPrint();
代码示例来源:origin: igniterealtime/Openfire
OutputFormat prettyPrinter = OutputFormat.createPrettyPrint();
XMLWriter xmlWriter = new XMLWriter(writer, prettyPrinter);
xmlWriter.write(xmlResponse);
代码示例来源:origin: igniterealtime/Openfire
OutputFormat prettyPrinter = OutputFormat.createPrettyPrint();
XMLWriter xmlWriter = new XMLWriter(writer, prettyPrinter);
try {
代码示例来源:origin: igniterealtime/Openfire
OutputFormat prettyPrinter = OutputFormat.createPrettyPrint();
XMLWriter xmlWriter = new XMLWriter(writer, prettyPrinter);
xmlWriter.write(xml);
代码示例来源:origin: mrdear/JavaWEB
/**
* 把document对象写入新的文件
*
* @param document
* @throws Exception
*/
public static void writer(Document document, OutputStreamWriter outputStream, String encoding) throws Exception {
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding(encoding);
XMLWriter writer = new XMLWriter(outputStream, format);
writer.write(document);
writer.flush();
writer.close();
}
代码示例来源:origin: webx/citrus
/** 输出DOM。 */
public static void writeDocument(Document doc, Writer writer, String charset) throws IOException {
charset = defaultIfEmpty(trimToNull(charset), "UTF-8");
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding(charset);
format.setIndent(true);
format.setIndentSize(4);
XMLWriter xmlWriter = new XMLWriter(writer, format);
xmlWriter.write(doc);
xmlWriter.flush();
}
代码示例来源:origin: webx/citrus
/** 输出DOM。 */
public static void writeDocument(Document doc, Writer writer, String charset) throws IOException {
charset = defaultIfEmpty(trimToNull(charset), "UTF-8");
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding(charset);
format.setIndent(true);
format.setIndentSize(4);
XMLWriter xmlWriter = new XMLWriter(writer, format);
xmlWriter.write(doc);
xmlWriter.flush();
}
代码示例来源:origin: webx/citrus
/** 输出DOM。 */
public static void writeDocument(Document doc, Writer writer, String charset) throws IOException {
charset = defaultIfEmpty(trimToNull(charset), "UTF-8");
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding(charset);
format.setIndent(true);
format.setIndentSize(4);
XMLWriter xmlWriter = new XMLWriter(writer, format);
xmlWriter.write(doc);
xmlWriter.flush();
}
代码示例来源:origin: youseries/urule
OutputFormat format=OutputFormat.createPrettyPrint();
format.setEncoding("utf-8");
XMLWriter writer=new XMLWriter(out,format);
代码示例来源:origin: org.dom4j/dom4j
org.dom4j.DocumentException {
StringWriter sw = new StringWriter();
OutputFormat format = OutputFormat.createPrettyPrint();
format.setNewlines(newlines);
format.setTrimText(trim);
代码示例来源:origin: pentaho/pentaho-kettle
OutputFormat format = org.dom4j.io.OutputFormat.createPrettyPrint();
代码示例来源:origin: dom4j/dom4j
public void testBug923882asWriterWithEmptyCharArray() throws Exception {
// use an the HTMLWriter sax-methods.
//
StringWriter buffer = new StringWriter();
HTMLWriter writer = new HTMLWriter(buffer, OutputFormat
.createPrettyPrint());
writer.characters("wor".toCharArray(), 0, 3);
writer.characters(new char[0], 0, 0);
writer.characters("d-being-cut".toCharArray(), 0, 11);
String expected = "word-being-cut";
assertEquals(expected, buffer.toString());
}
内容来源于网络,如有侵权,请联系作者删除!