Class NewlineCompleter

java.lang.Object
java.io.Reader
java.io.FilterReader
eu.bandm.tools.util.files.NewlineCompleter
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public class NewlineCompleter extends FilterReader
A secondary Reader that supplies one single newline at the end of the file, if there is none.
  • Field Details

    • isEnded

      boolean isEnded
      Whether the last character has been read from the peer reader.
    • lastWasLf

      boolean lastWasLf
      Whether the last read character was a newline or a carriage return character.
  • Constructor Details

    • NewlineCompleter

      public NewlineCompleter(Reader in)
      Only constructor
      Parameters:
      in - the underyling reader
  • Method Details

    • read

      public int read() throws IOException
      Append one last final newline character, if reading has ended with a character neither newline nor carriage return.
      Overrides:
      read in class FilterReader
      Returns:
      the read character
      Throws:
      IOException