Class EolAwareOutputStream

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

    class EolAwareOutputStream
    extends java.io.OutputStream
    An output stream which is aware of newlines and can be asked to begin a new line if not already in one.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean bol  
      private java.io.OutputStream out  
    • Constructor Summary

      Constructors 
      Constructor Description
      EolAwareOutputStream​(java.io.OutputStream out)
      Initialize a new EOL aware stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void beginln()
      Begin a new line if not already in one.
      (package private) boolean isBeginln()  
      void write​(byte[] buf, int pos, int cnt)
      void write​(int val)
      • Methods inherited from class java.io.OutputStream

        close, flush, nullOutputStream, write
      • Methods inherited from class java.lang.Object

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

      • out

        private final java.io.OutputStream out
      • bol

        private boolean bol
    • Constructor Detail

      • EolAwareOutputStream

        EolAwareOutputStream​(java.io.OutputStream out)
        Initialize a new EOL aware stream.
        Parameters:
        out - stream to output all writes to.
    • Method Detail

      • beginln

        void beginln()
              throws java.io.IOException
        Begin a new line if not already in one.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • isBeginln

        boolean isBeginln()
        Returns:
        true if a new line has just begun.
      • write

        public void write​(int val)
                   throws java.io.IOException
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] buf,
                          int pos,
                          int cnt)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException