cz.jalasoft.util.configuration.source.FileConfigSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JalasoftUtils Show documentation
Show all versions of JalasoftUtils Show documentation
A collection of utility classes that might be useful.
The newest version!
package cz.jalasoft.util.configuration.source;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* @author Honza Lastovicka ([email protected])
* @since 2016-07-27.
*/
final class FileConfigSource implements ConfigSource {
private final Path file;
public FileConfigSource(Path file) {
this.file = file;
}
public FileConfigSource(String file) {
this(Paths.get(file));
}
@Override
public Reader load() throws IOException {
Reader result = Files.newBufferedReader(file, Charset.forName("UTF-8"));
return result;
}
@Override
public String name() {
return file.toString();
}
}