Package java.io

Class PrintStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable, Modified

    public class PrintStream
    extends OutputStream
    implements Modified
    Wraps an existing OutputStream and provides convenience methods for writing common data types in a human readable format. No IOException is 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!
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void print​(boolean b)
      Prints a boolean as a string to the output stream.
      void print​(char c)
      Prints a single ascii char (8bit) to the output stream.
      void print​(char[] chars)
      Prints chars.length ascii chars (8bit each char) to the output stream.
      int print​(char[] b, int off, int count)
      Prints len ascii chars (8bit each char) starting at offset to this output stream.
      void print​(double val)
      Prints a double as a string to the output stream.
      void print​(float val)
      Prints a float as a string to the output stream.
      void print​(int val)
      Prints a integer as a string to the output stream.
      void print​(long val)
      Prints a long as a string to the output stream.
      int print​(String str)
      Prints a string to the output stream.
      void printHex​(int val)
      Prints a integer in hexadezimal notation as a string to the output stream.
      void printHex​(long val)
      Prints a long in hexadezimal notation as a string to the output stream.
      void printHexln​(int val)
      Prints a integer in hexadezimal notation as a string to the output stream and then terminates the line.
      void printHexln​(long val)
      Prints a long in hexadezimal notation as a string to the output stream and then terminates the line.
      void println()
      Terminates the line.
      void println​(boolean b)
      Prints a boolean as a string to the output stream and then terminates the line.
      void println​(char c)
      Prints a single ascii char (8bit) to the output stream and then terminates the line.
      void println​(char[] chars)
      Prints chars.length ascii chars (8bit each char) to the output stream and then terminates the line.
      void println​(double val)
      Prints a double as a string to the output stream and then terminates the line.
      void println​(float val)
      Prints a float as a string to the output stream and then terminates the line.
      void println​(int val)
      Prints a integer as a string to the output stream and then terminates the line.
      void println​(long val)
      Prints a long as a string to the output stream and then terminates the line.
      int println​(String str)
      Prints a string to the output stream and then terminates the line.
      void write​(int b)
      Writes one byte to the target stream.
    • Constructor Detail

    • Method Detail

      • write

        public void write​(int b)
        Writes one byte to the target stream. Only the least significant byte of the integer oneByte is written.
        Specified by:
        write in class OutputStream
        Parameters:
        b - the byte to be written
      • println

        public void println()
        Terminates the line.
      • print

        public void print​(char c)
        Prints a single ascii char (8bit) to the output stream.
        Parameters:
        c - the char to write.
      • println

        public void println​(char c)
        Prints a single ascii char (8bit) to the output stream and then terminates the line.
        Parameters:
        c - the char to write.
      • print

        public void print​(char[] chars)
        Prints chars.length ascii chars (8bit each char) to the output stream.
        Parameters:
        chars - the chars to write
      • println

        public void println​(char[] chars)
        Prints chars.length ascii 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)
        Prints len ascii chars (8bit each char) starting at offset to this output stream.
        Parameters:
        b - the char array
        off - 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.