Skip to content

Commit b53f6fc

Browse files
committed
Simplify Resources.inputStreamToByteArray
1 parent 81d957c commit b53f6fc

File tree

1 file changed

+1
-19
lines changed
  • substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk

1 file changed

+1
-19
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Resources.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,11 @@ public EconomicMap<Pair<String, String>, ResourceStorageEntry> resources() {
8181
}
8282

8383
public static byte[] inputStreamToByteArray(InputStream is) {
84-
// TODO: Replace this with is.readAllBytes() once Java 8 support is removed
85-
byte[] arr = new byte[4096];
86-
int pos = 0;
8784
try {
88-
for (;;) {
89-
if (pos == arr.length) {
90-
byte[] tmp = new byte[arr.length * 2];
91-
System.arraycopy(arr, 0, tmp, 0, arr.length);
92-
arr = tmp;
93-
}
94-
int len = is.read(arr, pos, arr.length - pos);
95-
if (len == -1) {
96-
break;
97-
}
98-
pos += len;
99-
}
85+
return is.readAllBytes();
10086
} catch (IOException ex) {
10187
throw VMError.shouldNotReachHere(ex);
10288
}
103-
104-
byte[] data = new byte[pos];
105-
System.arraycopy(arr, 0, data, 0, pos);
106-
return data;
10789
}
10890

10991
private static void addEntry(String moduleName, String resourceName, boolean isDirectory, byte[] data) {

0 commit comments

Comments
 (0)