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

uk.co.mruoc.properties.DefaultFileContentLoader 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.properties;

import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;

public class DefaultFileContentLoader implements FileContentLoader {

    private final InputStreamConverter converter = new InputStreamConverter();
    private final InputStreamLoader inputStreamLoader;

    public DefaultFileContentLoader(InputStreamLoader inputStreamLoader) {
        this.inputStreamLoader = inputStreamLoader;
    }

    @Override
    public String loadContent(String path) {
        try (InputStream stream = toStream(path)) {
            return converter.toString(stream);
        } catch (IOException | UncheckedIOException e) {
            throw new FileContentLoadException(path, e);
        }
    }

    private InputStream toStream(String path) {
        return inputStreamLoader.load(path);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy