本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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;
}