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