类 Out


  • public class Out
    extends java.lang.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 Computer Science: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.

    • 构造器概要

      构造器 
      构造器 说明
      Out()
      Initializes an output stream from standard output.
      Out​(java.io.OutputStream os)
      Initializes an output stream from a OutputStream.
      Out​(java.lang.String filename)
      Initializes an output stream from a file.
      Out​(java.net.Socket socket)
      Initializes an output stream from a socket.
    • 方法概要

      修饰符和类型 方法 说明
      void close()
      Closes the output stream.
      static void main​(java.lang.String[] args)
      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 print​(java.lang.Object x)
      Prints an object to this output stream and flushes this output stream.
      void printf​(java.lang.String format, java.lang.Object... args)
      Prints a formatted string to this output stream, using the specified format string and arguments, and then flushes this output stream.
      void printf​(java.util.Locale locale, java.lang.String format, java.lang.Object... args)
      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 println​(java.lang.Object x)
      Prints an object to this output stream and then terminates the line.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • Out

        public Out​(java.io.OutputStream os)
        Initializes an output stream from a OutputStream.
        参数:
        os - the OutputStream
      • Out

        public Out()
        Initializes an output stream from standard output.
      • Out

        public Out​(java.net.Socket socket)
        Initializes an output stream from a socket.
        参数:
        socket - the socket
      • Out

        public Out​(java.lang.String filename)
        Initializes an output stream from a file.
        参数:
        filename - the name of the file
    • 方法详细资料

      • close

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

        public void println()
        Terminates the current line by printing the line-separator string.
      • println

        public void println​(java.lang.Object x)
        Prints an object to this output stream and then terminates the line.
        参数:
        x - the object to print
      • println

        public void println​(boolean x)
        Prints a boolean to this output stream and then terminates the line.
        参数:
        x - the boolean to print
      • println

        public void println​(char x)
        Prints a character to this output stream and then terminates the line.
        参数:
        x - the character to print
      • println

        public void println​(double x)
        Prints a double to this output stream and then terminates the line.
        参数:
        x - the double to print
      • println

        public void println​(float x)
        Prints a float to this output stream and then terminates the line.
        参数:
        x - the float to print
      • println

        public void println​(int x)
        Prints an integer to this output stream and then terminates the line.
        参数:
        x - the integer to print
      • println

        public void println​(long x)
        Prints a long to this output stream and then terminates the line.
        参数:
        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.

        参数:
        x - the byte to print
      • print

        public void print()
        Flushes this output stream.
      • print

        public void print​(java.lang.Object x)
        Prints an object to this output stream and flushes this output stream.
        参数:
        x - the object to print
      • print

        public void print​(boolean x)
        Prints a boolean to this output stream and flushes this output stream.
        参数:
        x - the boolean to print
      • print

        public void print​(char x)
        Prints a character to this output stream and flushes this output stream.
        参数:
        x - the character to print
      • print

        public void print​(double x)
        Prints a double to this output stream and flushes this output stream.
        参数:
        x - the double to print
      • print

        public void print​(float x)
        Prints a float to this output stream and flushes this output stream.
        参数:
        x - the float to print
      • print

        public void print​(int x)
        Prints an integer to this output stream and flushes this output stream.
        参数:
        x - the integer to print
      • print

        public void print​(long x)
        Prints a long integer to this output stream and flushes this output stream.
        参数:
        x - the long integer to print
      • print

        public void print​(byte x)
        Prints a byte to this output stream and flushes this output stream.
        参数:
        x - the byte to print
      • printf

        public void printf​(java.lang.String format,
                           java.lang.Object... args)
        Prints a formatted string to this output stream, using the specified format string and arguments, and then flushes this output stream.
        参数:
        format - the format string
        args - the arguments accompanying the format string
      • printf

        public void printf​(java.util.Locale locale,
                           java.lang.String format,
                           java.lang.Object... args)
        Prints a formatted string to this output stream, using the specified locale, format string, and arguments, and then flushes this output stream.
        参数:
        locale - the locale
        format - the format string
        args - the arguments accompanying the format string
      • main

        public static void main​(java.lang.String[] args)
        A test client.
        参数:
        args - the command-line arguments