fix: return null when loading an inexistent resource
This commit is contained in:
parent
45f52ff123
commit
ff4aa3dcfd
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user