Class DelimitedRandomAccessFile

java.lang.Object
java.io.RandomAccessFile
gov.nih.mipav.model.file.DelimitedRandomAccessFile
All Implemented Interfaces:
Closeable, DataInput, DataOutput, AutoCloseable

public class DelimitedRandomAccessFile extends RandomAccessFile
This class is a random access file that has an internal delimiter for fast processing of text files. It can be used to read in legacy text files, such as comma-separated VOIs.
Author:
Justin Senseney
  • Field Details

    • delim

      private char delim
      The delimiter that separates each str chunk.
  • Constructor Details

    • DelimitedRandomAccessFile

      public DelimitedRandomAccessFile(String name, String mode, char delim) throws FileNotFoundException
      This constructor first performs the same actions as RandomAccessFile(String name, String mode), it then sets the file's delimiter to delim.
      Throws:
      FileNotFoundException
      See Also:
      • invalid reference
        RandomAccessFile(String name, String mode)
    • DelimitedRandomAccessFile

      public DelimitedRandomAccessFile(File file, String mode, char delim) throws FileNotFoundException
      This constructor first performs the same actions as RandomAccessFile(File file, String mode), it then sets the file's delimiter to delim.
      Throws:
      FileNotFoundException
      See Also:
      • invalid reference
        RandomAccessFile(File file, String mode)
  • Method Details

    • writeDelimitedBytes

      public void writeDelimitedBytes(String str) throws IOException
      Writes a string terminated by the current delimiter.
      Parameters:
      str - the string to be written
      Throws:
      IOException
    • writeDelimitedBytes

      public void writeDelimitedBytes(String str, char tempDelim) throws IOException
      Allows for writing with a temporary delimiter.
      Parameters:
      tempDelim - delimiter to be used for this method call only
      Throws:
      IOException
      See Also:
    • readDelimitedBytes

      public String readDelimitedBytes() throws IOException
      Reads a string from the file up to the current delimiter. Note that an EOF exception is caught, with the final string of the file returned
      Returns:
      the read string
      Throws:
      IOException
      See Also:
    • readDelimitedBytes

      public String readDelimitedBytes(char tempDelim) throws IOException
      This method retrieves a String consisting of all characters from the current pointer location in the random access file and the temporary delimiter.
      Parameters:
      tempDelim - the temporary delimiter for this class
      Returns:
      the string up to tempDelim (exclusive)
      Throws:
      IOException
    • getDelimiter

      public char getDelimiter()
    • setDelimiter

      public void setDelimiter(char delim)
    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException