in src/main/java/org/apache/sling/testing/clients/util/InputStreamBodyWithLength.java [51:69]
private static long getResourceStreamLength(String resourcePath) throws TestingIOException {
int streamLength = 0;
InputStream stream = ResourceUtil.getResourceAsStream(resourcePath);
try {
for (int avail = stream.available(); avail > 0; avail = stream.available()) {
streamLength += avail;
stream.skip(avail);
}
} catch (IOException e) {
throw new TestingIOException("Could not read " + resourcePath + "!", e);
} finally {
try {
stream.close();
} catch (IOException e) {
// ignore
}
}
return streamLength;
}