com.powsybl.iidm.geodata.utils.InputUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powsybl-iidm-geodata Show documentation
Show all versions of powsybl-iidm-geodata Show documentation
The IIDM module to load geographical data on a network
The newest version!
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.iidm.geodata.utils;
import org.apache.commons.io.ByteOrderMark;
import org.apache.commons.io.input.BOMInputStream;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* @author Hugo Marcellin {@literal }
*/
public final class InputUtils {
private InputUtils() {
}
public static Reader toReader(Path path) throws IOException {
return new BufferedReader(new InputStreamReader(InputUtils.toBomInputStream(Files.newInputStream(path)), StandardCharsets.UTF_8));
}
public static BOMInputStream toBomInputStream(InputStream inputStream) throws IOException {
return BOMInputStream.builder().setInputStream(inputStream).setByteOrderMarks(ByteOrderMark.UTF_8).get();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy