All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.co.mruoc.file.line.DefaultFileLineLoader Maven / Gradle / Ivy

Go to download

Code library to easily load files and file from the classpath or file system file

There is a newer version: 7.0.4
Show newest version
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