Skip to content

Commit

Permalink
Code: Fix IntelliJ issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
smarkwal committed Sep 24, 2024
1 parent 251e980 commit dea3d0e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions jarhc/src/testFixtures/java/org/jarhc/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ public static InputStream getResourceAsStream(String resource) throws IOExceptio

public static String getResourceAsString(String resource, String encoding) throws IOException {
if (resource == null) throw new IllegalArgumentException("resource");
InputStream stream = getResourceAsStream(resource);
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
while (true) {
int len = stream.read(buffer);
if (len < 0) break;
result.write(buffer, 0, len);
try (InputStream stream = getResourceAsStream(resource)) {
byte[] buffer = new byte[1024];
while (true) {
int len = stream.read(buffer);
if (len < 0) break;
result.write(buffer, 0, len);
}
}
return result.toString(encoding);
}
Expand Down

0 comments on commit dea3d0e

Please sign in to comment.