2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.ihc.internal.ws;
15 import static org.junit.jupiter.api.Assertions.*;
17 import java.io.BufferedReader;
18 import java.io.IOException;
19 import java.io.InputStream;
20 import java.io.InputStreamReader;
21 import java.io.Reader;
22 import java.util.stream.Collectors;
25 * Util class to load file content from resource files.
27 * @author Pauli Anttila - Initial contribution
29 public class ResourceFileUtils {
30 public static String getFileContent(String resourceFile) {
31 try (InputStream inputStream = ResourceFileUtils.class.getClassLoader().getResourceAsStream(resourceFile);
32 Reader inputStreamReader = new InputStreamReader(inputStream);
33 BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
34 return bufferedReader.lines().collect(Collectors.joining("\n"));
35 } catch (IOException e) {
36 fail("IOException reading xml file '" + resourceFile + "': " + e);