Avoid UnsupportedEncodingException & use const from StandardCharsets (#11948)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp
2022-01-03 16:05:08 +01:00
committed by GitHub
parent 3f54327d5a
commit 167f8ebc49
52 changed files with 180 additions and 414 deletions

View File

@@ -22,7 +22,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -37,12 +37,12 @@ import com.google.gson.stream.JsonWriter;
@NonNullByDefault
public class SDMDataUtil {
public static Reader openDataReader(String fileName) throws UnsupportedEncodingException, FileNotFoundException {
public static Reader openDataReader(String fileName) throws FileNotFoundException {
String packagePath = (SDMDataUtil.class.getPackage().getName()).replaceAll("\\.", "/");
String filePath = "src/test/resources/" + packagePath + "/" + fileName;
InputStream inputStream = new FileInputStream(filePath);
return new InputStreamReader(inputStream, "UTF-8");
return new InputStreamReader(inputStream, StandardCharsets.UTF_8);
}
public static <T> T fromJson(String fileName, Class<T> dataClass) throws IOException {