Class DiffWriter

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

    public class DiffWriter
    extends java.io.Writer
    Implements a writer that provides an additional method writeNewLine() that can be used for writing line separators which can be defined. A PrintWriter would actually be better, but it does not support defining the line separator to use.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String LS_NATIVE
      native line separator
      static java.lang.String LS_UNIX
      unix line separator
      static java.lang.String LS_WINDOWS
      windows line separator
    • Constructor Summary

      Constructors 
      Constructor Description
      DiffWriter​(java.io.Writer out)
      DiffWriter​(java.io.Writer out, java.lang.String lineSeparator)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      void flush()
      void write​(char[] cbuf)
      void write​(char[] cbuf, int off, int len)
      void write​(int c)
      void write​(java.lang.String str)
      void write​(java.lang.String str, int off, int len)
      void writeNewLine()
      Writes a new line according to the defined line separator
      • Methods inherited from class java.io.Writer

        append, append, append, nullWriter
      • Methods inherited from class java.lang.Object

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

      • LS_NATIVE

        public static final java.lang.String LS_NATIVE
        native line separator
      • LS_UNIX

        public static final java.lang.String LS_UNIX
        unix line separator
        See Also:
        Constant Field Values
      • LS_WINDOWS

        public static final java.lang.String LS_WINDOWS
        windows line separator
        See Also:
        Constant Field Values
    • Constructor Detail

      • DiffWriter

        public DiffWriter​(java.io.Writer out)
      • DiffWriter

        public DiffWriter​(java.io.Writer out,
                          java.lang.String lineSeparator)
        Parameters:
        lineSeparator - the line seperator to use for writeNewLine()
    • Method Detail

      • writeNewLine

        public void writeNewLine()
                          throws java.io.IOException
        Writes a new line according to the defined line separator
        Throws:
        java.io.IOException - if an I/O error occurs
      • write

        public void write​(int c)
                   throws java.io.IOException
        Overrides:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • write

        public void write​(char[] cbuf)
                   throws java.io.IOException
        Overrides:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • write

        public void write​(char[] cbuf,
                          int off,
                          int len)
                   throws java.io.IOException
        Specified by:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • write

        public void write​(java.lang.String str)
                   throws java.io.IOException
        Overrides:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • write

        public void write​(java.lang.String str,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in class java.io.Writer
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Writer
        Throws:
        java.io.IOException