uk.co.mruoc.file.line.DefaultFileLineLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of file-loader Show documentation
Show all versions of file-loader Show documentation
Code library to easily load files and file from the classpath or file system file
package uk.co.mruoc.file.line;
import lombok.RequiredArgsConstructor;
import uk.co.mruoc.file.BufferedReaderLoader;
import uk.co.mruoc.file.FileLoadException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Collection;
import java.util.stream.Collectors;
@RequiredArgsConstructor
public class DefaultFileLineLoader implements FileLineLoader {
private final BufferedReaderLoader bufferedReaderLoader;
@Override
public Collection loadLines(String path) {
try (BufferedReader reader = bufferedReaderLoader.load(path)) {
return reader.lines().collect(Collectors.toList());
} catch (IOException | UncheckedIOException e) {
throw new FileLoadException(path, e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy