Example usage for java.io FileDescriptor in

List of usage examples for java.io FileDescriptor in

Introduction

In this page you can find the example usage for java.io FileDescriptor in.

Prototype

FileDescriptor in

To view the source code for java.io FileDescriptor in.

Click Source Link

Document

A handle to the standard input stream.

Usage

From source file:org.springframework.shell.core.JLineShell.java

protected ConsoleReader createAnsiWindowsReader() throws Exception {
    // Get decorated OutputStream that parses ANSI-codes
    final PrintStream ansiOut = (PrintStream) ClassUtils
            .forName(ANSI_CONSOLE_CLASSNAME, JLineShell.class.getClassLoader()).getMethod("out").invoke(null);
    WindowsTerminal ansiTerminal = new WindowsTerminal() {
        @Override/*from   w  w w.  ja  v a  2 s  .  c om*/
        public boolean isANSISupported() {
            return true;
        }
    };
    ansiTerminal.initializeTerminal();
    // Make sure to reset the original shell's colors on shutdown by closing the stream
    statusListener = new ShellStatusListener() {
        public void onShellStatusChange(final ShellStatus oldStatus, final ShellStatus newStatus) {
            if (newStatus.getStatus().equals(Status.SHUTTING_DOWN)) {
                ansiOut.close();
            }
        }
    };
    addShellStatusListener(statusListener);

    return new ConsoleReader(new FileInputStream(FileDescriptor.in),
            new PrintWriter(new OutputStreamWriter(ansiOut,
                    // Default to Cp850 encoding for Windows console output (ROO-439)
                    System.getProperty("jline.WindowsTerminal.output.encoding", "Cp850"))),
            null, ansiTerminal);
}