
public class OutputStreamLogger extends OutputStreamWriter
close(), with a special
 newline handling and always flushing.
 
 This is meant to wrap logging output to the console.| Modifier and Type | Field and Description | 
|---|---|
protected static char | 
CARRIAGE_RETURN
Carriage return character. 
 | 
private int | 
charsSinceNewline
Flag to signal if we have had a newline recently. 
 | 
static String | 
NEWLINE
Newline string. 
 | 
static char[] | 
NEWLINEC
Newline as char array. 
 | 
static char | 
UNIX_NEWLINE
Unix newline 
 | 
static String | 
WHITESPACE
Whitespace. 
 | 
| Constructor and Description | 
|---|
OutputStreamLogger(OutputStream out)
Constructor. 
 | 
OutputStreamLogger(OutputStream out,
                  Charset cs)
Constructor. 
 | 
OutputStreamLogger(OutputStream out,
                  CharsetEncoder enc)
Constructor. 
 | 
OutputStreamLogger(OutputStream out,
                  String charsetName)
Constructor. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
close()
Close command - will be IGNORED. 
 | 
private int | 
countNonNewline(char[] cbuf,
               int off,
               int len)
Count the number of non-newline characters before first newline in the string. 
 | 
private int | 
countNonNewline(String str,
               int off,
               int len)
Count the number of non-newline characters before first newline in the string. 
 | 
private int | 
tailingNonNewline(char[] cbuf,
                 int off,
                 int len)
Count the tailing non-newline characters. 
 | 
private int | 
tailingNonNewline(String str,
                 int off,
                 int len)
Count the tailing non-newline characters. 
 | 
void | 
write(char[] cbuf,
     int off,
     int len)
Writer that keeps track of when it hasn't seen a newline yet, will
 auto-insert newlines except when lines start with a carriage return. 
 | 
void | 
write(String str,
     int off,
     int len)
Writer that keeps track of when it hasn't seen a newline yet, will
 auto-insert newlines except when lines start with a carriage return. 
 | 
flush, getEncoding, writeprivate int charsSinceNewline
protected static final char CARRIAGE_RETURN
public static final char UNIX_NEWLINE
public static final String NEWLINE
public static final char[] NEWLINEC
public static final String WHITESPACE
public OutputStreamLogger(OutputStream out)
out - Output streampublic OutputStreamLogger(OutputStream out, String charsetName) throws UnsupportedEncodingException
out - Output streamcharsetName - Character set nameUnsupportedEncodingException - thrown on unknown character setspublic OutputStreamLogger(OutputStream out, Charset cs)
out - Output Streamcs - Character set to usepublic OutputStreamLogger(OutputStream out, CharsetEncoder enc)
out - Output Streamenc - Charset encoderpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamWriterprivate int tailingNonNewline(char[] cbuf,
                    int off,
                    int len)
cbuf - Character bufferoff - Offsetlen - Rangeprivate int tailingNonNewline(String str, int off, int len)
str - Stringoff - Offsetlen - Rangeprivate int countNonNewline(char[] cbuf,
                  int off,
                  int len)
cbuf - character bufferoff - offsetlen - lengthprivate int countNonNewline(String str, int off, int len)
str - Stringoff - offsetlen - lengthpublic void write(char[] cbuf,
         int off,
         int len)
           throws IOException
write in class OutputStreamWriterIOExceptionpublic void write(String str, int off, int len) throws IOException
write in class OutputStreamWriterIOException