fix: return null when loading an inexistent resource

This commit is contained in:
TopchetoEU 2024-12-11 11:53:29 +02:00
parent 45f52ff123
commit ff4aa3dcfd
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4

View File

@ -17,6 +17,8 @@ public class Reading {
} }
public static byte[] streamToBytes(InputStream in) { public static byte[] streamToBytes(InputStream in) {
if (in == null) return null;
try { try {
List<byte[]> bufs = null; List<byte[]> bufs = null;
byte[] result = null; byte[] result = null;
@ -73,7 +75,9 @@ public class Reading {
catch (IOException e) { throw new UncheckedIOException(e); } catch (IOException e) { throw new UncheckedIOException(e); }
} }
public static String streamToString(InputStream in) { public static String streamToString(InputStream in) {
return new String(streamToBytes(in)); var bytes = streamToBytes(in);
if (bytes == null) return null;
else return new String(bytes);
} }
public static InputStream resourceToStream(String name) { public static InputStream resourceToStream(String name) {