Class ArffUtilities


  • public class ArffUtilities
    extends java.lang.Object
    Utility class for handling Arff dataset files.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int countDatasetEntries​(java.io.File file, boolean hasHeader)
      Counts the amount of datapoint entries in an ARFF file.
      static java.lang.String extractArffHeader​(java.io.File file)
      Extract the header of an ARFF file as a string.
      static void skipWithReaderToDatapoints​(java.io.BufferedReader reader)
      Skips with a given reader all comment lines and the header lines of an ARFF file until the first datapoint is reached.
      • Methods inherited from class java.lang.Object

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

      • extractArffHeader

        public static java.lang.String extractArffHeader​(java.io.File file)
                                                  throws java.io.IOException
        Extract the header of an ARFF file as a string.
        Parameters:
        file - Given ARFF file of which the header shall be extracted.
        Returns:
        Header of the given ARFF file.
        Throws:
        java.io.IOException - Could not read from the given file.
      • countDatasetEntries

        public static int countDatasetEntries​(java.io.File file,
                                              boolean hasHeader)
                                       throws java.io.IOException
        Counts the amount of datapoint entries in an ARFF file.
        Parameters:
        file - Given ARFF file where the entries are written in.
        hasHeader - If true the count will start after an '@data' annotation, otherwise it will just count every line, which is not a comment.
        Returns:
        Amount of datapoint entries.
        Throws:
        java.io.IOException - Could not read from the given file.
      • skipWithReaderToDatapoints

        public static void skipWithReaderToDatapoints​(java.io.BufferedReader reader)
                                               throws java.io.IOException
        Skips with a given reader all comment lines and the header lines of an ARFF file until the first datapoint is reached.
        Parameters:
        reader - Reader that should be skipped to the data.
        Throws:
        java.io.IOException - Reader was not able to read the file.