/*************************************************************************
* Compilation: javac [Link]
* Execution: java StdOut
*
* Writes data of various types to standard output.
*
*************************************************************************/
import [Link];
import [Link];
import [Link];
import [Link];
/**
* <i>Standard output</i>. This class provides methods for writing strings
* and numbers to standard output.
* <p>
* For additional documentation, see <a
href="[Link] 1.5</a> of
* <i>Introduction to Programming in Java: An Interdisciplinary Approach</i> by
Robert Sedgewick and Kevin Wayne.
*/
public final class StdOut {
// force Unicode UTF-8 encoding; otherwise it's system dependent
private static final String UTF8 = "UTF-8";
// assume language = English, country = US for consistency with StdIn
private static final Locale US_LOCALE = new Locale("en", "US");
// send output here
private static PrintWriter out;
// this is called before invoking any methods
static {
try {
out = new PrintWriter(new OutputStreamWriter([Link], UTF8), true);
}
catch (UnsupportedEncodingException e) { [Link](e); }
}
// singleton pattern - can't instantiate
private StdOut() { }
// close the output stream (not required)
/**
* Close standard output.
*/
public static void close() {
[Link]();
}
/**
* Terminate the current line by printing the line separator string.
*/
public static void println() {
[Link]();
}
/**
* Print an object to standard output and then terminate the line.
*/
public static void println(Object x) {
[Link](x);
}
/**
* Print a boolean to standard output and then terminate the line.
*/
public static void println(boolean x) {
[Link](x);
}
/**
* Print a char to standard output and then terminate the line.
*/
public static void println(char x) {
[Link](x);
}
/**
* Print a double to standard output and then terminate the line.
*/
public static void println(double x) {
[Link](x);
}
/**
* Print a float to standard output and then terminate the line.
*/
public static void println(float x) {
[Link](x);
}
/**
* Print an int to standard output and then terminate the line.
*/
public static void println(int x) {
[Link](x);
}
/**
* Print a long to standard output and then terminate the line.
*/
public static void println(long x) {
[Link](x);
}
/**
* Print a short to standard output and then terminate the line.
*/
public static void println(short x) {
[Link](x);
}
/**
* Print a byte to standard output and then terminate the line.
*/
public static void println(byte x) {
[Link](x);
}
/**
* Flush standard output.
*/
public static void print() {
[Link]();
}
/**
* Print an Object to standard output and flush standard output.
*/
public static void print(Object x) {
[Link](x);
[Link]();
}
/**
* Print a boolean to standard output and flush standard output.
*/
public static void print(boolean x) {
[Link](x);
[Link]();
}
/**
* Print a char to standard output and flush standard output.
*/
public static void print(char x) {
[Link](x);
[Link]();
}
/**
* Print a double to standard output and flush standard output.
*/
public static void print(double x) {
[Link](x);
[Link]();
}
/**
* Print a float to standard output and flush standard output.
*/
public static void print(float x) {
[Link](x);
[Link]();
}
/**
* Print an int to standard output and flush standard output.
*/
public static void print(int x) {
[Link](x);
[Link]();
}
/**
* Print a long to standard output and flush standard output.
*/
public static void print(long x) {
[Link](x);
[Link]();
}
/**
* Print a short to standard output and flush standard output.
*/
public static void print(short x) {
[Link](x);
[Link]();
}
/**
* Print a byte to standard output and flush standard output.
*/
public static void print(byte x) {
[Link](x);
[Link]();
}
/**
* Print a formatted string to standard output using the specified
* format string and arguments, and flush standard output.
*/
public static void printf(String format, Object... args) {
[Link](US_LOCALE, format, args);
[Link]();
}
/**
* Print a formatted string to standard output using the specified
* locale, format string, and arguments, and flush standard output.
*/
public static void printf(Locale locale, String format, Object... args) {
[Link](locale, format, args);
[Link]();
}
// This method is just here to test the class
public static void main(String[] args) {
// write to stdout
[Link]("Test");
[Link](17);
[Link](true);
[Link]("%.6f\n", 1.0/7.0);
}