Package ghidra.framework.main.logviewer.model

# Class ReverseLineReader

java.lang.Object
ghidra.framework.main.logviewer.model.ReverseLineReader

public class ReverseLineReader extends Object
Reads in a single line of text from a given input file, in reverse order. CONOPS: 1. Start at a given position in the file and read BUFFER_SIZE bytes into a byte array 2. From the end of the array, read a character 3. If the character represents a newline (or carriage return), the line is finished, so return. 4. If not, continue reading.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `RandomAccessFile`
  `raf`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ReverseLineReader(String encoding, RandomAccessFile raf)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `readLine()`
  Reads a single line from the current file pointer position, in reverse.
  `void`
  `setFilePos(long position)`
  Moves the file pointer to the given byte location.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### raf

    public RandomAccessFile raf

- ## Constructor Details

  - ### ReverseLineReader

    public ReverseLineReader(String encoding, RandomAccessFile raf) throws IOException
    Parameters:
      `encoding` -
      `raf` -
    Throws:
      `IOException`

- ## Method Details

  - ### setFilePos

    public void setFilePos(long position)
    Moves the file pointer to the given byte location.
    Parameters:
      `position` -

  - ### readLine

    public String readLine() throws IOException
    Reads a single line from the current file pointer position, in reverse. To do this we do the following: 1. Read a 'large enough' number of bytes into a buffer (enough to guarantee a full line of text. 2. Move backwards through the bytes just read until a newline or carriage return is found. 3. Throw away the rest of the bytes and return the line found.
    Returns:
    Throws:
      `IOException`