當前位置: 首頁>>代碼示例>>Java>>正文


Java OutputFormat.setLineSeparator方法代碼示例

本文整理匯總了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);
}
  }
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:30,代碼來源:SearchEngineSupport.java

示例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();
        }
    }
}
 
開發者ID:OSBI,項目名稱:mondrian,代碼行數:22,代碼來源:XmlUtility.java

示例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);
    }
}
 
開發者ID:sharwell,項目名稱:zgrnbviewer,代碼行數:17,代碼來源:Viewer.java

示例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();
}
 
開發者ID:chelu,項目名稱:jdal,代碼行數:24,代碼來源:XMLUtils.java

示例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);
}
  }
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:21,代碼來源:StorageUtil.java

示例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);
}
  }
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:21,代碼來源:StorageUtil.java

示例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);}
   }
 
開發者ID:sharwell,項目名稱:zgrnbviewer,代碼行數:11,代碼來源:Utils.java


注:本文中的org.apache.xml.serialize.OutputFormat.setLineSeparator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。