Class TextStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class TextStream
    extends java.io.FilterOutputStream
    This class implements an output stream that has additional methods for printing. It is similar to java.io.PrintStream except that it does not swallow exceptions.
    • Field Summary

      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      TextStream​(java.io.OutputStream out)
      Creates a new TextStream.
      TextStream​(java.io.OutputStream out, boolean autoflush)
      Creates a new TextStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void print​(java.lang.String s)
      Prints a String.
      void println()
      Prints a newline.
      void println​(java.lang.String s)
      Prints a string followed by a newline.
      • Methods inherited from class java.io.FilterOutputStream

        close, flush, write, write, write
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TextStream

        public TextStream​(java.io.OutputStream out)
        Creates a new TextStream.
        Parameters:
        out - the output stream
      • TextStream

        public TextStream​(java.io.OutputStream out,
                          boolean autoflush)
        Creates a new TextStream.
        Parameters:
        out - the output stream
        autoflush - set to true to flush the stream after each newline character is written
    • Method Detail

      • print

        public void print​(java.lang.String s)
                   throws java.io.IOException
        Prints a String.
        Parameters:
        s - the String to be printed
        Throws:
        java.io.IOException - if there is a problem writing to the stream
      • println

        public void println()
                     throws java.io.IOException
        Prints a newline.
        Throws:
        java.io.IOException - if there is a problem writing to the stream
      • println

        public void println​(java.lang.String s)
                     throws java.io.IOException
        Prints a string followed by a newline.
        Parameters:
        s - the String to be printed
        Throws:
        java.io.IOException - if there is a problem writing to the stream