本文整理汇总了Java中org.apache.xml.serialize.OutputFormat.setLineSeparator方法的典型用法代码示例。如果您正苦于以下问题:Java OutputFormat.setLineSeparator方法的具体用法?Java OutputFormat.setLineSeparator怎么用?Java OutputFormat.setLineSeparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xml.serialize.OutputFormat
的用法示例。
在下文中一共展示了OutputFormat.setLineSeparator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: store
import org.apache.xml.serialize.OutputFormat; //导入方法依赖的package包/类
/**
* store loaded data to xml file
* @throws SearchException
*/
protected final synchronized void store() throws SearchException {
//Collection.Key[] keys=collections.keys();
Iterator<Key> it = collections.keyIterator();
Key k;
while(it.hasNext()) {
k=it.next();
Element collEl = getCollectionElement(k.getString());
SearchCollection sc = getCollectionByName(k.getString());
setAttributes(collEl,sc);
}
OutputFormat format = new OutputFormat(doc, null, true);
format.setLineSeparator("\r\n");
format.setLineWidth(72);
OutputStream os=null;
try {
XMLSerializer serializer = new XMLSerializer(os=IOUtil.toBufferedOutputStream(searchFile.getOutputStream()), format);
serializer.serialize(doc.getDocumentElement());
} catch (IOException e) {
throw new SearchException(e);
}
finally {
IOUtil.closeEL(os);
}
}
示例2: save
import org.apache.xml.serialize.OutputFormat; //导入方法依赖的package包/类
public static void save(Writer writer, Document document)
throws IOException
{
OutputFormat outputFormat = new OutputFormat(document);
outputFormat.setIndenting(true);
outputFormat.setLineWidth(Integer.MAX_VALUE);
outputFormat.setLineSeparator(Util.nl);
try {
XMLSerializer serializer = new XMLSerializer(writer, outputFormat);
serializer.serialize(document);
} finally {
if (writer != null) {
writer.close();
}
}
}
示例3: exportSVG
import org.apache.xml.serialize.OutputFormat; //导入方法依赖的package包/类
void exportSVG(File f) {
SVGWriter sw = new SVGWriter();
if (f.exists()) {
f.delete();
}
Document d = sw.exportVirtualSpace(svgSpace, new DOMImplementationImpl(), f);
OutputFormat format = new OutputFormat(d, SVG_OUTPUT_ENCODING, true);
format.setLineSeparator(LineSeparator.Web);
try {
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(f), SVG_OUTPUT_ENCODING);
DOMSerializer serializer = (new XMLSerializer(osw, format)).asDOMSerializer();
serializer.serialize(d);
} catch (IOException e) {
Exceptions.printStackTrace(e);
}
}
示例4: prettyDocumentToString
import org.apache.xml.serialize.OutputFormat; //导入方法依赖的package包/类
/**
* Serialize a Document to a String using JAXP with identation (4 spaces)
* @param doc to serialize
* @return xml string
*/
public static String prettyDocumentToString(Document doc) {
StringWriter writer = new StringWriter();
OutputFormat out = new OutputFormat();
out.setOmitXMLDeclaration(true);
out.setIndenting(true);
out.setIndent(4);
out.setLineSeparator(System.getProperty("line.separator"));
out.setLineWidth(Integer.MAX_VALUE);
XMLSerializer serializer = new XMLSerializer(writer, out);
try {
Element rootElement = doc.getDocumentElement();
serializer.serialize(rootElement);
} catch (IOException e) {
log.error(e);
}
return writer.toString();
}
示例5: store
import org.apache.xml.serialize.OutputFormat; //导入方法依赖的package包/类
/**
* store loaded data to xml file
* @param doc
* @param res
* @throws IOException
*/
public synchronized void store(Document doc,Resource res) throws IOException {
OutputFormat format = new OutputFormat(doc, null, true);
format.setLineSeparator("\r\n");
format.setLineWidth(72);
OutputStream os=null;
try {
XMLSerializer serializer = new XMLSerializer(os=res.getOutputStream(), format);
serializer.serialize(doc.getDocumentElement());
}
finally {
IOUtil.closeEL(os);
}
}
示例6: store
import org.apache.xml.serialize.OutputFormat; //导入方法依赖的package包/类
/**
* store loaded data to xml file
* @param doc
* @param res
* @throws IOException
*/
public void store(Document doc,Resource res) throws IOException {
OutputFormat format = new OutputFormat(doc, null, true);
format.setLineSeparator("\r\n");
format.setLineWidth(72);
OutputStream os=null;
try {
XMLSerializer serializer = new XMLSerializer(os=res.getOutputStream(), format);
serializer.serialize(doc.getDocumentElement());
}
finally {
IOUtil.closeEL(os);
}
}
示例7: serialize
import org.apache.xml.serialize.OutputFormat; //导入方法依赖的package包/类
public static void serialize(Document d,FileObject f){
OutputFormat format=new OutputFormat(d, SVG_OUTPUT_ENCODING, true);
format.setLineSeparator(LineSeparator.Web);
try {
OutputStreamWriter osw = new OutputStreamWriter(f.getOutputStream(), SVG_OUTPUT_ENCODING);
DOMSerializer serializer = (new XMLSerializer(osw, format)).asDOMSerializer();
serializer.serialize(d);
}
catch (IOException e){Exceptions.printStackTrace(e);}
}