当前位置: 首页>>代码示例>>Java>>正文


Java AnsiOutputStream类代码示例

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


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

示例1: wrapOutputStream

import org.fusesource.jansi.AnsiOutputStream; //导入依赖的package包/类
/**
 * Returns an ansi output stream handler. We return whatever was
 * passed if we determine we cannot handle ansi based on Kernel32 calls.
 * 
 * @return an @{link AltWindowAnsiOutputStream} instance or the passed 
 * stream.
 */
private static OutputStream wrapOutputStream(final OutputStream stream) {
    String os = System.getProperty("os.name");
    if( os.startsWith("Windows") ) {
        // On windows we know the console does not interpret ANSI codes..
        try {
            return new WindowsAnsiOutputStream(stream);
        } catch (Throwable ignore) {
            // this happens when JNA is not in the path.. or
            // this happens when the stdout is being redirected to a file.
        }
        // Use the ANSIOutputStream to strip out the ANSI escape sequences.
        return new AnsiOutputStream(stream);
    }
    return stream;
}
 
开发者ID:CyberdyneCC,项目名称:ThermosRebased,代码行数:23,代码来源:AnsiWindowsTerminal.java

示例2: stripAnsi

import org.fusesource.jansi.AnsiOutputStream; //导入依赖的package包/类
private String stripAnsi(String str) {
    if (str == null) return "";
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        AnsiOutputStream aos = new AnsiOutputStream(baos);
        aos.write(str.getBytes());
        aos.flush();
        return baos.toString();
    } catch (IOException e) {
        return str;
    }
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:13,代码来源:ConsoleReader.java

示例3: wrapOutputStream

import org.fusesource.jansi.AnsiOutputStream; //导入依赖的package包/类
/**
 * Returns an ansi output stream handler. We return whatever was
 * passed if we determine we cannot handle ansi based on Kernel32 calls.
 * 
 * @return an @{link AltWindowAnsiOutputStream} instance or the passed 
 * stream.
 */
private static OutputStream wrapOutputStream(final OutputStream stream) {
    if (Configuration.isWindows()) {
        // On windows we know the console does not interpret ANSI codes..
        try {
            return new WindowsAnsiOutputStream(stream);
        } catch (Throwable ignore) {
            // this happens when JNA is not in the path.. or
            // this happens when the stdout is being redirected to a file.
        }
        // Use the ANSIOutputStream to strip out the ANSI escape sequences.
        return new AnsiOutputStream(stream);
    }
    return stream;
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:22,代码来源:AnsiWindowsTerminal.java

示例4: ansiColored

import org.fusesource.jansi.AnsiOutputStream; //导入依赖的package包/类
public String ansiColored(String message) {
    if (!printColored) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        AnsiOutputStream ansiStream = new AnsiOutputStream(byteArrayOutputStream);
        try {
            ansiStream.write(message.getBytes());
        } catch (IOException e) {
        }
        return byteArrayOutputStream.toString();
    }

    return message;
}
 
开发者ID:albertlatacz,项目名称:java-repl,代码行数:14,代码来源:ResultPrinter.java


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