Class FileUtils

java.lang.Object
org.aksw.iguana.cc.utils.files.FileUtils

public class FileUtils extends Object
Methods to work easier with Files.
Author:
f.conrads
  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • getHashcodeFromFileContent

      public static int getHashcodeFromFileContent(Path filepath)
      This method calculates the hashcode of the content of a file.
      The hashcode is calculated using the XXHash64 algorithm.
      Parameters:
      filepath - the path of the file
      Returns:
      the hashcode of the file content
    • getHashcodeFromDirectory

      public static int getHashcodeFromDirectory(Path directory)
      This method calculated the hashcode of a directory by hashing the content of all files in the directory.
      Only top-level files are considered, subdirectories are ignored.
      The hashcode is calculated using the XXHash64 algorithm.
      Parameters:
      directory - the path of the directory
      Returns:
      the hashcode of the directory content
    • getLineEnding

      public static String getLineEnding(Path filepath) throws IOException
      This method detects and returns the line-ending used in a file.
      It reads the whole first line until it detects one of the following line-endings:
      • \r\n - Windows
      • \n - Linux
      • \r - old macOS
      If the file doesn't contain a line ending, it defaults to System.lineSeparator().
      Parameters:
      filepath - this string that contains the path of the file
      Returns:
      the line ending used in the given file
      Throws:
      IOException - if an I/O error occurs opening the file
    • indexStream

      public static List<QueryIndex> indexStream(String separator, InputStream is) throws IOException
      Throws:
      IOException