Class TextStreamInput

  • All Implemented Interfaces:
    Input<java.lang.String>, java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    TextFileInput

    public class TextStreamInput
    extends java.lang.Object
    implements Input<java.lang.String>
    The input implementation designed to read the text lines from the given input stream using BufferedReader
    • Field Summary

      • Fields inherited from interface com.github.akurilov.commons.io.Input

        DELIMITER
    • Constructor Summary

      Constructors 
      Constructor Description
      TextStreamInput​(java.io.InputStream input)  
      TextStreamInput​(java.io.InputStream input, int buffSize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.lang.String get()
      Get next item
      int get​(java.util.List<java.lang.String> buffer, int limit)
      Get some lines
      void reset()
      Most probably will cause an IOException
      long skip​(long count)
      Skips characters instead of lines
      • Methods inherited from class java.lang.Object

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

      • TextStreamInput

        public TextStreamInput​(java.io.InputStream input)
      • TextStreamInput

        public TextStreamInput​(java.io.InputStream input,
                               int buffSize)
    • Method Detail

      • get

        public java.lang.String get()
                             throws java.io.EOFException,
                                    java.io.IOException
        Description copied from interface: Input
        Get next item
        Specified by:
        get in interface Input<java.lang.String>
        Returns:
        next text line from the given input stream
        Throws:
        java.io.EOFException - if no item available more
        java.io.IOException - if failed to get some-why
      • get

        public int get​(java.util.List<java.lang.String> buffer,
                       int limit)
                throws java.io.IOException
        Get some lines
        Specified by:
        get in interface Input<java.lang.String>
        Parameters:
        buffer - buffer for the text lines
        limit - max count of the text lines to put into the buffer
        Returns:
        the count of the text lines was got
        Throws:
        java.io.EOFException - if no item available more
        java.io.IOException - if failed to get some-why
      • skip

        public long skip​(long count)
                  throws java.io.IOException
        Skips characters instead of lines
        Specified by:
        skip in interface Input<java.lang.String>
        Parameters:
        count - count of items should be skipped from the input stream
        Throws:
        java.io.IOException - if failed to skip such amount of bytes
      • reset

        public void reset()
                   throws java.io.IOException
        Most probably will cause an IOException
        Specified by:
        reset in interface Input<java.lang.String>
        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
        Throws:
        java.io.IOException