JBoss STDIO 1.0.0.CR1

org.jboss.stdio
Class StdioContext

java.lang.Object
  extended by org.jboss.stdio.StdioContext

public final class StdioContext
extends java.lang.Object

A context for console input and output.


Method Summary
static StdioContext create(java.io.InputStream in, java.io.OutputStream out, java.io.OutputStream err)
          Create a console I/O context.
static StdioContext create(java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err)
          Create a console I/O context.
 java.io.PrintStream getErr()
          Get the error stream for this context.
 java.io.InputStream getIn()
          Get the input stream for this context.
 java.io.PrintStream getOut()
          Get the output stream for this context.
static StdioContext getStdioContext()
          Get the current console I/O context.
static void install()
          Install the StdioContext streams.
static void setStdioContextSelector(StdioContextSelector stdioContextSelector)
          Set the standard I/O context selector.
static void uninstall()
          Uninstall the StdioContext streams.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static StdioContext create(java.io.InputStream in,
                                  java.io.PrintStream out,
                                  java.io.PrintStream err)
                           throws java.lang.SecurityException
Create a console I/O context.

Parameters:
in - the input stream for this context
out - the output stream for this context
err - the error stream for this context
Returns:
the new context
Throws:
java.lang.SecurityException - if the caller does not have the createStdioContext RuntimePermission

create

public static StdioContext create(java.io.InputStream in,
                                  java.io.OutputStream out,
                                  java.io.OutputStream err)
                           throws java.lang.SecurityException
Create a console I/O context. The given output streams are wrapped in PrintStream instances.

Parameters:
in - the input stream for this context
out - the output stream for this context
err - the error stream for this context
Returns:
the new context
Throws:
java.lang.SecurityException - if the caller does not have the createStdioContext RuntimePermission

getStdioContext

public static StdioContext getStdioContext()
Get the current console I/O context.

Returns:
the current context

getIn

public java.io.InputStream getIn()
Get the input stream for this context.

Returns:
the input stream

getOut

public java.io.PrintStream getOut()
Get the output stream for this context.

Returns:
the output stream

getErr

public java.io.PrintStream getErr()
Get the error stream for this context.

Returns:
the error stream

install

public static void install()
                    throws java.lang.SecurityException,
                           java.lang.IllegalStateException
Install the StdioContext streams.

Throws:
java.lang.SecurityException - if the caller does not have the installStdioContextSelector RuntimePermission
java.lang.IllegalStateException - if the streams are already installed

uninstall

public static void uninstall()
                      throws java.lang.SecurityException,
                             java.lang.IllegalStateException
Uninstall the StdioContext streams.

Throws:
java.lang.SecurityException - if the caller does not have the installStdioContextSelector RuntimePermission
java.lang.IllegalStateException - if the streams are already uninstalled

setStdioContextSelector

public static void setStdioContextSelector(StdioContextSelector stdioContextSelector)
                                    throws java.lang.SecurityException
Set the standard I/O context selector. You must have the setStdioContextSelector RuntimePermission in order to invoke this method.

Parameters:
stdioContextSelector - the selector to use
Throws:
java.lang.SecurityException - if the caller does not have the installStdioContextSelector RuntimePermission

JBoss STDIO 1.0.0.CR1

Copyright © 2010 JBoss, a division of Red Hat, Inc.