Package monq.jfa

Class ReaderCharSource

java.lang.Object
monq.jfa.ReaderCharSource
All Implemented Interfaces:
CharSource

public class ReaderCharSource extends Object implements CharSource
Wraps a Reader or an input stream to provide a CharSource.

NOTE: This class has no close() method. Any wrappend closeable input must be closed by the code providing it.

  • Constructor Details

    • ReaderCharSource

      public ReaderCharSource(Reader in)
    • ReaderCharSource

      public ReaderCharSource(InputStream in, Charset chSet)

      Wraps the InputStream into a Reader, using an encoding for the given character set.

      The Reader used internally cannot be closed. Anyone who thinks this is a problem, please let me know. But don't forget to close the InputStream eventually.

  • Method Details

    • read

      public int read() throws IOException
      Description copied from interface: CharSource
      returns a single character or -1 to indicate end of file.
      Specified by:
      read in interface CharSource
      Throws:
      IOException
    • mark

      public void mark()
      Description copied from interface: CharSource
      Sets a mark until which we may want to skip back with CharSource.backToMark() to re-read part of the input. The initial mark is always at the start of the input, so that after a call to backToMark the whole CharSource can be re-read.
      Specified by:
      mark in interface CharSource
    • backToMark

      public int backToMark()
      Description copied from interface: CharSource
      Resets this to a previously set CharSource.mark().
      Specified by:
      backToMark in interface CharSource