当前位置: 首页>>代码示例>>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;未经允许,请勿转载。