• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LineSeparator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jdom2.output.LineSeparator的典型用法代码示例。如果您正苦于以下问题:Java LineSeparator类的具体用法?Java LineSeparator怎么用?Java LineSeparator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LineSeparator类属于org.jdom2.output包,在下文中一共展示了LineSeparator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sloppyPrint

import org.jdom2.output.LineSeparator; //导入依赖的package包/类
/**
 * Creates an outputter and writes an XML tree.
 *
 * The encoding argument here only sets an attribute in the
 * XML declaration. It's up to the caller to ensure the writer
 * is encoding bytes to match. If encoding is null, the default
 * is "UTF-8".
 *
 * If XML character entity escaping is allowed, otherwise unmappable
 * characters may be written without errors. If disabled, an
 * UnmappableCharacterException will make their presence obvious and fatal.
 *
 * LineEndings will be CR-LF. Except for comments!?
 *
 * @param doc
 * @param writer
 * @param disableEscaping
 */
public static void sloppyPrint( Document doc, Writer writer, String encoding, boolean allowEscaping ) throws IOException {
	Format format = Format.getPrettyFormat();
	format.setTextMode( Format.TextMode.PRESERVE );  // Permit leading/trailing space.
	format.setExpandEmptyElements( false );
	format.setOmitDeclaration( false );
	format.setIndent( "\t" );
	format.setLineSeparator( LineSeparator.CRNL );

	if ( encoding != null ) {
		format.setEncoding( encoding );
	}

	if ( !allowEscaping ) {
		format.setEscapeStrategy(new EscapeStrategy() {
			@Override
			public boolean shouldEscape( char ch ) {
				return false;
			}
		});
	}

	XMLOutputter outputter = new XMLOutputter( format, new SloppyXMLOutputProcessor() );
	outputter.output( doc, writer );
}
 
开发者ID:Vhati,项目名称:Slipstream-Mod-Manager,代码行数:43,代码来源:SloppyXMLOutputProcessor.java


示例2: getRawContents

import org.jdom2.output.LineSeparator; //导入依赖的package包/类
public String getRawContents(final Document dom) throws IOException {
    final Format format = Format.getRawFormat();
    format.setLineSeparator(LineSeparator.UNIX);
    final XMLOutputter outputter = new XMLOutputter(format, new StandaloneOutputProcessor());
    final Writer writer = new StringWriter();
    outputter.output(dom, writer);
    return writer.toString();
}
 
开发者ID:ayakovlevgh,项目名称:jodtemplate,代码行数:9,代码来源:JDOMHelper.java


示例3: convertElementToText

import org.jdom2.output.LineSeparator; //导入依赖的package包/类
public static String convertElementToText(final Element element) throws IOException {
    final Format format = Format.getRawFormat();
    format.setLineSeparator(LineSeparator.UNIX);
    final XMLOutputter outputter = new XMLOutputter(format, new StandaloneOutputProcessor());
    final Writer writer = new StringWriter();
    outputter.output(element, writer);
    return writer.toString();
}
 
开发者ID:ayakovlevgh,项目名称:jodtemplate,代码行数:9,代码来源:TestUtils.java


示例4: convertDocumentToText

import org.jdom2.output.LineSeparator; //导入依赖的package包/类
public static String convertDocumentToText(final Document document) throws IOException {
    final Format format = Format.getRawFormat();
    format.setLineSeparator(LineSeparator.UNIX);
    final XMLOutputter outputter = new XMLOutputter(format, new StandaloneOutputProcessor());
    final Writer writer = new StringWriter();
    outputter.output(document, writer);
    return writer.toString();
}
 
开发者ID:ayakovlevgh,项目名称:jodtemplate,代码行数:9,代码来源:TestUtils.java


示例5: kafToStr

import org.jdom2.output.LineSeparator; //导入依赖的package包/类
/**
     * Returns a string containing the XML content of a KAFDocument object.
     */
    static String kafToStr(KAFDocument kaf) {
        XMLOutputter out = new XMLOutputter(Format.getPrettyFormat().setLineSeparator(LineSeparator.UNIX));
//		out.getFormat().setTextMode(Format.TextMode.PRESERVE);
        Document jdom = KAFToDOM(kaf);
        return out.outputString(jdom);
    }
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:10,代码来源:ReadWriteManager.java


示例6: sloppyPrint

import org.jdom2.output.LineSeparator; //导入依赖的package包/类
/**
 * Creates an outputter and writes an XML tree.
 *
 * The encoding argument here only sets an attribute in the
 * XML declaration. It's up to the caller to ensure the writer
 * is encoding bytes to match. If encoding is null, the default
 * is "UTF-8".
 *
 * LineEndings will be CR-LF. Except for comments!?
 */
public static void sloppyPrint( Document doc, Writer writer, String encoding ) throws IOException
{
	Format format = Format.getPrettyFormat();
	format.setExpandEmptyElements( false );
	format.setOmitDeclaration( false );
	format.setIndent( "\t" );
	format.setLineSeparator( LineSeparator.CRNL );

	if ( encoding != null ) format.setEncoding( encoding );

	XMLOutputter outputter = new XMLOutputter( format, new SloppyXMLOutputProcessor() );
	outputter.output( doc, writer );
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:24,代码来源:SloppyXMLOutputProcessor.java


示例7: determineEOL

import org.jdom2.output.LineSeparator; //导入依赖的package包/类
private static LineSeparator determineEOL( File pom )
    throws ManipulationException
{
    try (  BufferedInputStream bufferIn = new BufferedInputStream( new FileInputStream( pom ) ) )
    {
        int prev = -1;
        int ch;
        while ( ( ch = bufferIn.read() ) != -1 )
        {
            if ( ch == '\n' )
            {
                if ( prev == '\r' )
                {
                    return LineSeparator.CRNL;
                }
                else
                {
                    return LineSeparator.NL;
                }
            }
            else if ( prev == '\r' )
            {
                return LineSeparator.CR;
            }
            prev = ch;
        }
        throw new ManipulationException( "Could not determine end-of-line marker mode" );
    }
    catch ( IOException ioe )
    {
        throw new ManipulationException( "Could not determine end-of-line marker mode", ioe );
    }
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:34,代码来源:PomIO.java


示例8: kafToStr

import org.jdom2.output.LineSeparator; //导入依赖的package包/类
/** Returns a string containing the XML content of a KAFDocument object. */
   static String kafToStr(KAFDocument kaf) {
XMLOutputter out = new XMLOutputter(Format.getPrettyFormat().setLineSeparator(LineSeparator.UNIX).setTextMode(Format.TextMode.TRIM_FULL_WHITE));
Document jdom = KAFToDOM(kaf);
return out.outputString(jdom);
   }
 
开发者ID:Elhuyar,项目名称:Elixa,代码行数:7,代码来源:ReadWriteManager.java


示例9: write

import org.jdom2.output.LineSeparator; //导入依赖的package包/类
public void write(final Document dom, final OutputStream stream) throws IOException {
    final Format format = Format.getRawFormat();
    format.setLineSeparator(LineSeparator.UNIX);
    final XMLOutputter outputter = new XMLOutputter(format, new StandaloneOutputProcessor());
    outputter.output(dom, stream);
}
 
开发者ID:ayakovlevgh,项目名称:jodtemplate,代码行数:7,代码来源:JDOMHelper.java



注:本文中的org.jdom2.output.LineSeparator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ObjectReader类代码示例发布时间:2022-05-23
下一篇:
Java JCatalog类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap