2 * Copyright (c) 2010-2022 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.luftdateninfo.internal.util;
15 import static org.junit.jupiter.api.Assertions.*;
17 import java.io.BufferedReader;
18 import java.io.FileInputStream;
19 import java.io.IOException;
20 import java.io.InputStreamReader;
22 import org.eclipse.jdt.annotation.NonNullByDefault;
23 import org.eclipse.jdt.annotation.Nullable;
26 * The {@link FileReader} Helper Util to read test resource files
28 * @author Bernd Weymann - Initial contribution
31 public class FileReader {
33 public static @Nullable String readFileInString(String filename) {
34 try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "CP1252"));) {
35 StringBuffer buf = new StringBuffer();
38 while ((sCurrentLine = br.readLine()) != null) {
39 buf.append(sCurrentLine);
41 return buf.toString();
42 } catch (IOException e) {
43 // fail if file cannot be read