Class CharacterFilterReader

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

    public class CharacterFilterReader
    extends AbstractCharacterFilterReader
    A filter reader that filters out a given character represented as an int code point, handy to remove known junk characters from CSV files for example. This class is the most efficient way to filter out a single character, as opposed to using a CharacterSetFilterReader. You can also nest CharacterFilterReaders.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int skip  
      • Fields inherited from class java.io.FilterReader

        in
      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      CharacterFilterReader​(java.io.Reader reader, int skip)
      Constructs a new reader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean filter​(int ch)
      Returns true if the given character should be filtered out, false to keep the character.
      • Methods inherited from class java.io.FilterReader

        close, mark, markSupported, ready, reset, skip
      • Methods inherited from class java.io.Reader

        nullReader, read, read, transferTo
      • Methods inherited from class java.lang.Object

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

      • skip

        private final int skip
    • Constructor Detail

      • CharacterFilterReader

        public CharacterFilterReader​(java.io.Reader reader,
                                     int skip)
        Constructs a new reader.
        Parameters:
        reader - the reader to filter.
        skip - the character to filter out.
    • Method Detail

      • filter

        protected boolean filter​(int ch)
        Description copied from class: AbstractCharacterFilterReader
        Returns true if the given character should be filtered out, false to keep the character.
        Specified by:
        filter in class AbstractCharacterFilterReader
        Parameters:
        ch - the character to test.
        Returns:
        true if the given character should be filtered out, false to keep the character.