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

cz.jalasoft.util.configuration.source.FileConfigSource Maven / Gradle / Ivy

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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy