public final class StdioContext
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
StdioContext.DelegatingInputStream |
private static class |
StdioContext.DelegatingPrintStream |
private static class |
StdioContext.State |
| Modifier and Type | Field and Description |
|---|---|
private static java.security.Permission |
CREATE_CONTEXT_PERMISSION |
private static java.lang.ThreadLocal<java.lang.Boolean> |
entered |
private java.io.PrintStream |
err |
private java.io.InputStream |
in |
private static java.security.Permission |
INSTALL_PERMISSION |
private java.io.PrintStream |
out |
private static java.security.Permission |
SET_CONTEXT_SELECTOR_PERMISSION |
private static java.util.concurrent.atomic.AtomicReference<StdioContext.State> |
state |
private static StdioContextSelector |
stdioContextSelector |
private static StdioContext |
SYSTEM_STDIO_CONTEXT |
| Constructor and Description |
|---|
StdioContext(java.io.InputStream in,
java.io.PrintStream out,
java.io.PrintStream err) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
private static final StdioContext SYSTEM_STDIO_CONTEXT
private static final java.lang.ThreadLocal<java.lang.Boolean> entered
private static final java.security.Permission CREATE_CONTEXT_PERMISSION
private static final java.security.Permission SET_CONTEXT_SELECTOR_PERMISSION
private static final java.security.Permission INSTALL_PERMISSION
private static final java.util.concurrent.atomic.AtomicReference<StdioContext.State> state
private final java.io.InputStream in
private final java.io.PrintStream out
private final java.io.PrintStream err
private static volatile StdioContextSelector stdioContextSelector
StdioContext(java.io.InputStream in,
java.io.PrintStream out,
java.io.PrintStream err)
public static StdioContext create(java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err) throws java.lang.SecurityException
in - the input stream for this contextout - the output stream for this contexterr - the error stream for this contextjava.lang.SecurityException - if the caller does not have the createStdioContext RuntimePermissionpublic static StdioContext create(java.io.InputStream in, java.io.OutputStream out, java.io.OutputStream err) throws java.lang.SecurityException
PrintStream instances.in - the input stream for this contextout - the output stream for this contexterr - the error stream for this contextjava.lang.SecurityException - if the caller does not have the createStdioContext RuntimePermissionpublic static StdioContext getStdioContext()
public java.io.InputStream getIn()
public java.io.PrintStream getOut()
public java.io.PrintStream getErr()
public static void install()
throws java.lang.SecurityException,
java.lang.IllegalStateException
java.lang.SecurityException - if the caller does not have the installStdioContextSelector RuntimePermissionjava.lang.IllegalStateException - if the streams are already installedpublic static void uninstall()
throws java.lang.SecurityException,
java.lang.IllegalStateException
java.lang.SecurityException - if the caller does not have the installStdioContextSelector RuntimePermissionjava.lang.IllegalStateException - if the streams are already uninstalledpublic static void setStdioContextSelector(StdioContextSelector stdioContextSelector) throws java.lang.SecurityException
setStdioContextSelector RuntimePermission in
order to invoke this method.stdioContextSelector - the selector to usejava.lang.SecurityException - if the caller does not have the installStdioContextSelector RuntimePermission