Package java.io
Class PrintStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.PrintStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,Modified
public class PrintStream extends OutputStream implements Modified
Wraps an existingOutputStreamand provides convenience methods for writing common data types in a human readable format. NoIOExceptionis thrown by this class. Instead, the stack trace is written to the err- stream. This class puts special focus on efficiency. No strings are allocated during write operations!
-
-
Constructor Summary
Constructors Constructor Description PrintStream(OutputStream out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidprint(boolean b)Prints a boolean as a string to the output stream.voidprint(char c)Prints a single asciichar(8bit) to the output stream.voidprint(char[] chars)Printschars.lengthascii chars (8bit each char) to the output stream.intprint(char[] b, int off, int count)Printslenascii chars (8bit each char) starting atoffsetto this output stream.voidprint(double val)Prints a double as a string to the output stream.voidprint(float val)Prints a float as a string to the output stream.voidprint(int val)Prints a integer as a string to the output stream.voidprint(long val)Prints a long as a string to the output stream.intprint(String str)Prints a string to the output stream.voidprintHex(int val)Prints a integer in hexadezimal notation as a string to the output stream.voidprintHex(long val)Prints a long in hexadezimal notation as a string to the output stream.voidprintHexln(int val)Prints a integer in hexadezimal notation as a string to the output stream and then terminates the line.voidprintHexln(long val)Prints a long in hexadezimal notation as a string to the output stream and then terminates the line.voidprintln()Terminates the line.voidprintln(boolean b)Prints a boolean as a string to the output stream and then terminates the line.voidprintln(char c)Prints a single asciichar(8bit) to the output stream and then terminates the line.voidprintln(char[] chars)Printschars.lengthascii chars (8bit each char) to the output stream and then terminates the line.voidprintln(double val)Prints a double as a string to the output stream and then terminates the line.voidprintln(float val)Prints a float as a string to the output stream and then terminates the line.voidprintln(int val)Prints a integer as a string to the output stream and then terminates the line.voidprintln(long val)Prints a long as a string to the output stream and then terminates the line.intprintln(String str)Prints a string to the output stream and then terminates the line.voidwrite(int b)Writes one byte to the target stream.-
Methods inherited from class java.io.OutputStream
checkError, close, flush, write, write
-
-
-
-
Constructor Detail
-
PrintStream
public PrintStream(OutputStream out)
-
-
Method Detail
-
write
public void write(int b)
Writes one byte to the target stream. Only the least significant byte of the integeroneByteis written.- Specified by:
writein classOutputStream- Parameters:
b- the byte to be written
-
println
public void println()
Terminates the line.
-
print
public void print(char c)
Prints a single asciichar(8bit) to the output stream.- Parameters:
c- the char to write.
-
println
public void println(char c)
Prints a single asciichar(8bit) to the output stream and then terminates the line.- Parameters:
c- the char to write.
-
print
public void print(char[] chars)
Printschars.lengthascii chars (8bit each char) to the output stream.- Parameters:
chars- the chars to write
-
println
public void println(char[] chars)
Printschars.lengthascii chars (8bit each char) to the output stream and then terminates the line.- Parameters:
chars- the chars to write
-
print
public int print(char[] b, int off, int count)Printslenascii chars (8bit each char) starting atoffsetto this output stream.- Parameters:
b- the char arrayoff- the start offset in the data.count- the number of char to write- Returns:
- the number of written bytes.
-
print
public int print(String str)
Prints a string to the output stream.- Parameters:
str- The string to write.- Returns:
- The number of written chars.
-
println
public int println(String str)
Prints a string to the output stream and then terminates the line.- Parameters:
str- The string to write.- Returns:
- The number of written chars.
-
print
public void print(boolean b)
Prints a boolean as a string to the output stream.- Parameters:
b- the boolean to write.
-
println
public void println(boolean b)
Prints a boolean as a string to the output stream and then terminates the line.- Parameters:
b- the boolean to write.
-
print
public void print(int val)
Prints a integer as a string to the output stream.- Parameters:
val- the integer to write.
-
println
public void println(int val)
Prints a integer as a string to the output stream and then terminates the line.- Parameters:
val- the integer to write.
-
print
public void print(long val)
Prints a long as a string to the output stream.- Parameters:
val- the long to write.
-
println
public void println(long val)
Prints a long as a string to the output stream and then terminates the line.- Parameters:
val- the long to write.
-
print
public void print(float val)
Prints a float as a string to the output stream.- Parameters:
val- the float to write.
-
println
public void println(float val)
Prints a float as a string to the output stream and then terminates the line.- Parameters:
val- the float to write.
-
print
public void print(double val)
Prints a double as a string to the output stream.- Parameters:
val- the double to write.
-
println
public void println(double val)
Prints a double as a string to the output stream and then terminates the line.- Parameters:
val- the double to write.
-
printHex
public void printHex(int val)
Prints a integer in hexadezimal notation as a string to the output stream.- Parameters:
val- the integer to write.
-
printHexln
public void printHexln(int val)
Prints a integer in hexadezimal notation as a string to the output stream and then terminates the line.- Parameters:
val- the integer to write.
-
printHex
public void printHex(long val)
Prints a long in hexadezimal notation as a string to the output stream.- Parameters:
val- the long to write.
-
printHexln
public void printHexln(long val)
Prints a long in hexadezimal notation as a string to the output stream and then terminates the line.- Parameters:
val- the long to write.
-
-