Class ReverseFileReader

java.lang.Object
org.nuiton.util.ReverseFileReader
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable

public class ReverseFileReader
extends java.lang.Object
implements java.io.Closeable
Reverse file reader. Read file line by line for end of file to begin of file.
Author:
chatellier
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.lang.String filename  
    protected long position  
    protected java.io.RandomAccessFile randomfile  
  • Constructor Summary

    Constructors 
    Constructor Description
    ReverseFileReader​(java.io.File file)  
    ReverseFileReader​(java.lang.String filename)  
  • Method Summary

    Modifier and Type Method Description
    void close()  
    protected void finalize()  
    java.lang.String readLine()
    Read one line from the current position towards the beginning.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • filename

      protected java.lang.String filename
    • randomfile

      protected java.io.RandomAccessFile randomfile
    • position

      protected long position
  • Constructor Details

    • ReverseFileReader

      public ReverseFileReader​(java.io.File file) throws java.io.IOException
      Throws:
      java.io.IOException
    • ReverseFileReader

      public ReverseFileReader​(java.lang.String filename) throws java.io.IOException
      Throws:
      java.io.IOException
  • Method Details

    • readLine

      public java.lang.String readLine() throws java.io.IOException
      Read one line from the current position towards the beginning.
      Returns:
      the next line of text from this file, or null if end of file is encountered before even one byte is read.
      Throws:
      java.io.IOException - if any pb while reading line
    • 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
    • finalize

      protected void finalize() throws java.lang.Throwable
      Overrides:
      finalize in class java.lang.Object
      Throws:
      java.lang.Throwable