Avoid UnsupportedEncodingException & use const from StandardCharsets (#11948)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
committed by
GitHub
parent
3f54327d5a
commit
167f8ebc49
@@ -17,7 +17,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.measure.Unit;
|
||||
@@ -65,11 +65,11 @@ public final class WWNDataUtil {
|
||||
// Hidden utility class constructor
|
||||
}
|
||||
|
||||
public static Reader openDataReader(String fileName) throws UnsupportedEncodingException {
|
||||
public static Reader openDataReader(String fileName) {
|
||||
String packagePath = (WWNDataUtil.class.getPackage().getName()).replaceAll("\\.", "/");
|
||||
String filePath = "/" + packagePath + "/" + fileName;
|
||||
InputStream inputStream = WWNDataUtil.class.getClassLoader().getResourceAsStream(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 {
|
||||
|
||||
Reference in New Issue
Block a user