Package stdlib
Class Out
java.lang.Object
stdlib.Out
This class provides methods for writing strings and numbers to
various output streams, including standard output, file, and sockets.
For additional documentation, see Section 3.1 of Computer Science: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.
- Author:
- Robert Sedgewick, Kevin Wayne
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the output stream.static void
A test client.void
print()
Flushes this output stream.void
print
(boolean x) Prints a boolean to this output stream and flushes this output stream.void
print
(byte x) Prints a byte to this output stream and flushes this output stream.void
print
(char x) Prints a character to this output stream and flushes this output stream.void
print
(double x) Prints a double to this output stream and flushes this output stream.void
print
(float x) Prints a float to this output stream and flushes this output stream.void
print
(int x) Prints an integer to this output stream and flushes this output stream.void
print
(long x) Prints a long integer to this output stream and flushes this output stream.void
Prints an object to this output stream and flushes this output stream.void
Prints a formatted string to this output stream, using the specified format string and arguments, and then flushes this output stream.void
Prints a formatted string to this output stream, using the specified locale, format string, and arguments, and then flushes this output stream.void
println()
Terminates the current line by printing the line-separator string.void
println
(boolean x) Prints a boolean to this output stream and then terminates the line.void
println
(byte x) Prints a byte to this output stream and then terminates the line.void
println
(char x) Prints a character to this output stream and then terminates the line.void
println
(double x) Prints a double to this output stream and then terminates the line.void
println
(float x) Prints a float to this output stream and then terminates the line.void
println
(int x) Prints an integer to this output stream and then terminates the line.void
println
(long x) Prints a long to this output stream and then terminates the line.void
Prints an object to this output stream and then terminates the line.
-
Constructor Details
-
Out
public Out()Initializes an output stream from standard output. -
Out
Initializes an output stream from a socket.- Parameters:
socket
- the socket
-
Out
Initializes an output stream from a file.- Parameters:
filename
- the name of the file
-
-
Method Details
-
close
public void close()Closes the output stream. -
println
public void println()Terminates the current line by printing the line-separator string. -
println
Prints an object to this output stream and then terminates the line.- Parameters:
x
- the object to print
-
println
public void println(boolean x) Prints a boolean to this output stream and then terminates the line.- Parameters:
x
- the boolean to print
-
println
public void println(char x) Prints a character to this output stream and then terminates the line.- Parameters:
x
- the character to print
-
println
public void println(double x) Prints a double to this output stream and then terminates the line.- Parameters:
x
- the double to print
-
println
public void println(float x) Prints a float to this output stream and then terminates the line.- Parameters:
x
- the float to print
-
println
public void println(int x) Prints an integer to this output stream and then terminates the line.- Parameters:
x
- the integer to print
-
println
public void println(long x) Prints a long to this output stream and then terminates the line.- Parameters:
x
- the long to print
-
println
public void println(byte x) Prints a byte to this output stream and then terminates the line.To write binary data, see
BinaryOut
.- Parameters:
x
- the byte to print
-
print
public void print()Flushes this output stream. -
print
Prints an object to this output stream and flushes this output stream.- Parameters:
x
- the object to print
-
print
public void print(boolean x) Prints a boolean to this output stream and flushes this output stream.- Parameters:
x
- the boolean to print
-
print
public void print(char x) Prints a character to this output stream and flushes this output stream.- Parameters:
x
- the character to print
-
print
public void print(double x) Prints a double to this output stream and flushes this output stream.- Parameters:
x
- the double to print
-
print
public void print(float x) Prints a float to this output stream and flushes this output stream.- Parameters:
x
- the float to print
-
print
public void print(int x) Prints an integer to this output stream and flushes this output stream.- Parameters:
x
- the integer to print
-
print
public void print(long x) Prints a long integer to this output stream and flushes this output stream.- Parameters:
x
- the long integer to print
-
print
public void print(byte x) Prints a byte to this output stream and flushes this output stream.- Parameters:
x
- the byte to print
-
printf
Prints a formatted string to this output stream, using the specified format string and arguments, and then flushes this output stream.- Parameters:
format
- the format stringargs
- the arguments accompanying the format string
-
printf
Prints a formatted string to this output stream, using the specified locale, format string, and arguments, and then flushes this output stream.- Parameters:
locale
- the localeformat
- the format stringargs
- the arguments accompanying the format string
-
main
A test client.- Parameters:
args
- the command-line arguments
-