FileReadingUtilities

public final class FileReadingUtilities

Utility class to help reading contents of files.

Author

jwienke

Methods

readFileLines

public static List<String> readFileLines(File file)

Reads the complete contents of a file into a list of lines. Any reading error is reported as an IOException.

Parameters

file – file to read

Throws

IOException – any error reading the file

Returns

file lines

readFirstFileLine

public static String readFirstFileLine(File file)

Reads the first line of a file into a string. Any reading error is reported as an IOException. This method is not intended for large files since all lines are read into memory before selecting the first line

Parameters

file – file to read

Throws

IOException – any error reading the file, also if file is empty

Returns

first file line