Package stdlib

Class Out

java.lang.Object
stdlib.Out

public class Out extends Object
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 Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Out()
    Create an Out object using standard output.
    Create an Out object using an OutputStream.
    Create an Out object using a file specified by the given name.
    Out(Socket socket)
    Create an Out object using a Socket.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the output stream.
    void
    format(String format, Object... args)
    Print a formatted string using the specified format string and arguments, and then flush the output stream.
    void
    format(Locale locale, String format, Object... args)
    Print a formatted string using the specified locale, format string and arguments, and then flush the output stream.
    static void
    main(String[] args)
    A test client.
    void
    Flush the output stream.
    void
    print(boolean x)
    Print an boolean and then flush the output stream.
    void
    print(byte x)
    Print a byte and then flush the output stream.
    void
    print(char x)
    Print an char and then flush the output stream.
    void
    print(double x)
    Print an double and then flush the output stream.
    void
    print(float x)
    Print a float and then flush the output stream.
    void
    print(int x)
    Print an int and then flush the output stream.
    void
    print(long x)
    Print a long and then flush the output stream.
    void
    Print an object and then flush the output stream.
    void
    printf(String format, Object... args)
     
    void
    printf(Locale locale, String format, Object... args)
     
    void
    Terminate the line.
    void
    println(boolean x)
    Print a boolean and then terminate the line.
    void
    println(byte x)
    Print a byte and then terminate the line.
    void
    println(char x)
    Print a char and then terminate the line.
    void
    println(double x)
    Print an double and then terminate the line.
    void
    println(float x)
    Print a float and then terminate the line.
    void
    println(int x)
    Print an int and then terminate the line.
    void
    println(long x)
    Print a long and then terminate the line.
    void
    Print an object and then terminate the line.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Out

      public Out(OutputStream os)
      Create an Out object using an OutputStream.
    • Out

      public Out()
      Create an Out object using standard output.
    • Out

      public Out(Socket socket)
      Create an Out object using a Socket.
    • Out

      public Out(String s)
      Create an Out object using a file specified by the given name.
  • Method Details

    • close

      public void close()
      Close the output stream.
    • println

      public void println()
      Terminate the line.
    • println

      public void println(Object x)
      Print an object and then terminate the line.
    • println

      public void println(boolean x)
      Print a boolean and then terminate the line.
    • println

      public void println(char x)
      Print a char and then terminate the line.
    • println

      public void println(double x)
      Print an double and then terminate the line.
    • println

      public void println(float x)
      Print a float and then terminate the line.
    • println

      public void println(int x)
      Print an int and then terminate the line.
    • println

      public void println(long x)
      Print a long and then terminate the line.
    • println

      public void println(byte x)
      Print a byte and then terminate the line.
    • print

      public void print()
      Flush the output stream.
    • print

      public void print(Object x)
      Print an object and then flush the output stream.
    • print

      public void print(boolean x)
      Print an boolean and then flush the output stream.
    • print

      public void print(char x)
      Print an char and then flush the output stream.
    • print

      public void print(double x)
      Print an double and then flush the output stream.
    • print

      public void print(float x)
      Print a float and then flush the output stream.
    • print

      public void print(int x)
      Print an int and then flush the output stream.
    • print

      public void print(long x)
      Print a long and then flush the output stream.
    • print

      public void print(byte x)
      Print a byte and then flush the output stream.
    • format

      public void format(String format, Object... args)
      Print a formatted string using the specified format string and arguments, and then flush the output stream.
    • printf

      public void printf(String format, Object... args)
    • format

      public void format(Locale locale, String format, Object... args)
      Print a formatted string using the specified locale, format string and arguments, and then flush the output stream.
    • printf

      public void printf(Locale locale, String format, Object... args)
    • main

      public static void main(String[] args)
      A test client.