Package org.aksw.iguana.cc.utils.files
Class FileUtils
java.lang.Object
org.aksw.iguana.cc.utils.files.FileUtils
Methods to work easier with Files.
- Author:
- f.conrads
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getHashcodeFromDirectory
(Path directory) This method calculated the hashcode of a directory by hashing the content of all files in the directory.static int
getHashcodeFromFileContent
(Path filepath) This method calculates the hashcode of the content of a file.static String
getLineEnding
(Path filepath) This method detects and returns the line-ending used in a file.static List<QueryIndex>
indexStream
(String separator, InputStream is)
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
getHashcodeFromFileContent
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
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
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
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
- Throws:
IOException
-