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