org.erights.e.develop.exception
Class PrintStreamWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--org.erights.e.develop.exception.PrintStreamWriter

public final class PrintStreamWriter
extends Writer

Untamed: This class shouldn't need to exist, but System.out and System.err are both PrintStreams, and PrintStream is deprecated in favor of PrintWriter.

XXX How should one obtain a Writer or PrintWriter to stdout and stderr? As long as we're at it, we also provide a static method for accessing System.in as a non-buffering BufferedReader (so that readline() is available).

Note that there is no reason to use this class as a type in a type declaration. No one should ever see any instances of it. Only its static methods are externally useful.

Note: As of some recent version of Java <= 1.3, PrintStream is no longer officially deprecated, probably because of System.out and System.err. However, E's TextWriters still need to wrap Writers, not PrintStreams, so we still need PrintStreamWriter.

Author:
Mark S. Miller

Field Summary
private static PrintStream lastErrStream
           
private static PrintWriter lastErrWriter
           
private static BufferedReader lastInReader
           
private static InputStream lastInStream
           
private static PrintStream lastOutStream
           
private static PrintWriter lastOutWriter
           
private  PrintStream myPS
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
private PrintStreamWriter(PrintStream ps)
           
 
Method Summary
 void close()
          Enabled:
 void flush()
          Enabled:
static PrintWriter make(PrintStream ps)
          Enabled: Wrap the PrintStream in an adaptor so it seems to be a PrintWriter.
static PrintWriter stderr()
          Enabled: System.err as a PrintWriter.
static BufferedReader stdin()
          Enabled:
static PrintWriter stdout()
          Enabled: System.out as a PrintWriter.
 void write(char[] cbuf, int off, int len)
          Enabled:
 
Methods inherited from class java.io.Writer
write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastOutStream

private static PrintStream lastOutStream

lastOutWriter

private static PrintWriter lastOutWriter

lastErrStream

private static PrintStream lastErrStream

lastErrWriter

private static PrintWriter lastErrWriter

lastInStream

private static InputStream lastInStream

lastInReader

private static BufferedReader lastInReader

myPS

private final PrintStream myPS
Constructor Detail

PrintStreamWriter

private PrintStreamWriter(PrintStream ps)
Method Detail

make

public static PrintWriter make(PrintStream ps)
Enabled: Wrap the PrintStream in an adaptor so it seems to be a PrintWriter.


stdout

public static PrintWriter stdout()
Enabled: System.out as a PrintWriter. It's a function rather than a variable in case System.out gets changed.


stderr

public static PrintWriter stderr()
Enabled: System.err as a PrintWriter. It's a function rather than a variable in case System.err gets changed.


stdin

public static BufferedReader stdin()
Enabled:


close

public void close()
Enabled:

Specified by:
close in class Writer

flush

public void flush()
Enabled:

Specified by:
flush in class Writer

write

public void write(char[] cbuf,
                  int off,
                  int len)
Enabled:

Specified by:
write in class Writer
Parameters:
cbuf - Array of characters
off - Offset from which to start writing characters
len - Number of characters to write


comments?