|
Copyright 2012-02-25 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.Writer
ch.randelshofer.io.PrintWriter2
public class PrintWriter2
Same as java.io.PrintWriter with an additional method setLineSeparator allowing to use a line separator that is not the default line separator of the underlying operating system.
| Field Summary | |
|---|---|
protected java.lang.String |
lineSeparator
Line separator string. |
protected java.io.Writer |
out
The underlying character-output stream of this PrintWriter. |
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
PrintWriter2(java.io.OutputStream out)
Create a new PrintWriter, without automatic line flushing, from an existing OutputStream. |
|
PrintWriter2(java.io.OutputStream out,
boolean autoFlush)
Create a new PrintWriter from an existing OutputStream. |
|
PrintWriter2(java.io.Writer out)
Create a new PrintWriter, without automatic line flushing. |
|
PrintWriter2(java.io.Writer out,
boolean autoFlush)
Create a new PrintWriter. |
|
| Method Summary | |
|---|---|
boolean |
checkError()
Flush the stream and check its error state. |
void |
close()
Close the stream. |
void |
flush()
Flush the stream. |
java.lang.String |
getLineSeparator()
|
void |
print(boolean b)
Print a boolean value. |
void |
print(char c)
Print a character. |
void |
print(char[] s)
Print an array of characters. |
void |
print(double d)
Print a double-precision floating-point number. |
void |
print(float f)
Print a floating-point number. |
void |
print(int i)
Print an integer. |
void |
print(long l)
Print a long integer. |
void |
print(java.lang.Object obj)
Print an object. |
void |
print(java.lang.String s)
Print a string. |
void |
println()
Terminate the current line by writing the line separator string. |
void |
println(boolean x)
Print a boolean value and then terminate the line. |
void |
println(char x)
Print a character and then terminate the line. |
void |
println(char[] x)
Print an array of characters and then terminate the line. |
void |
println(double x)
Print a double-precision floating-point number and then terminate the line. |
void |
println(float x)
Print a floating-point number and then terminate the line. |
void |
println(int x)
Print an integer and then terminate the line. |
void |
println(long x)
Print a long integer and then terminate the line. |
void |
println(java.lang.Object x)
Print an Object and then terminate the line. |
void |
println(java.lang.String x)
Print a String and then terminate the line. |
protected void |
setError()
Indicate that an error has occurred. |
void |
setLineSeparator(java.lang.String separator)
Sets the line separator for the writer. |
void |
write(char[] buf)
Write an array of characters. |
void |
write(char[] buf,
int off,
int len)
Write a portion of an array of characters. |
void |
write(int c)
Write a single character. |
void |
write(java.lang.String s)
Write a string. |
void |
write(java.lang.String s,
int off,
int len)
Write a portion of a string. |
| Methods inherited from class java.io.Writer |
|---|
append, append, append |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.io.Writer out
PrintWriter.
protected java.lang.String lineSeparator
| Constructor Detail |
|---|
public PrintWriter2(java.io.Writer out)
out - A character-output stream
public PrintWriter2(java.io.Writer out,
boolean autoFlush)
out - A character-output streamautoFlush - A boolean; if true, the println() methods will flush
the output bufferpublic PrintWriter2(java.io.OutputStream out)
out - An output streamOutputStreamWriter.OutputStreamWriter(java.io.OutputStream)
public PrintWriter2(java.io.OutputStream out,
boolean autoFlush)
out - An output streamautoFlush - A boolean; if true, the println() methods will flush
the output bufferOutputStreamWriter.OutputStreamWriter(java.io.OutputStream)| Method Detail |
|---|
public void setLineSeparator(java.lang.String separator)
public java.lang.String getLineSeparator()
public void flush()
flush in interface java.io.Flushableflush in class java.io.Writerpublic void close()
close in interface java.io.Closeableclose in class java.io.Writerpublic boolean checkError()
protected void setError()
public void write(int c)
write in class java.io.Writer
public void write(char[] buf,
int off,
int len)
write in class java.io.Writerpublic void write(char[] buf)
write in class java.io.Writer
public void write(java.lang.String s,
int off,
int len)
write in class java.io.Writerpublic void write(java.lang.String s)
write in class java.io.Writerpublic void print(boolean b)
String.valueOf(boolean) is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the write(int) method.
b - The boolean to be printedpublic void print(char c)
write(int) method.
c - The char to be printedpublic void print(int i)
String.valueOf(int) is translated into bytes according
to the platform's default character encoding, and these bytes are
written in exactly the manner of the write(int)
method.
i - The int to be printedInteger.toString(int)public void print(long l)
String.valueOf(long) is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the write(int)
method.
l - The long to be printedLong.toString(long)public void print(float f)
String.valueOf(float) is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the write(int)
method.
f - The float to be printedFloat.toString(float)public void print(double d)
String.valueOf(double) is translated into
bytes according to the platform's default character encoding, and these
bytes are written in exactly the manner of the write(int) method.
d - The double to be printedDouble.toString(double)public void print(char[] s)
write(int)
method.
s - The array of chars to be printed
java.lang.NullPointerException - If s is nullpublic void print(java.lang.String s)
null then the string
"null" is printed. Otherwise, the string's characters are
converted into bytes according to the platform's default character
encoding, and these bytes are written in exactly the manner of the
write(int) method.
s - The String to be printedpublic void print(java.lang.Object obj)
String.valueOf(Object) method is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the write(int)
method.
obj - The Object to be printedObject.toString()public void println()
line.separator, and is not necessarily a single newline
character ('\n').
public void println(boolean x)
print(boolean) and then
println().
public void println(char x)
print(char) and then println().
public void println(int x)
print(int) and then println().
public void println(long x)
print(long) and then
println().
public void println(float x)
print(float) and then
println().
public void println(double x)
print(double) and then println().
public void println(char[] x)
print(char[]) and then
println().
public void println(java.lang.String x)
print(String) and then
println().
public void println(java.lang.Object x)
print(Object) and then
println().
|
Copyright 2012-02-25 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||