We do not need the actual bytes read, hence we loop using a small-ish
buffer.
JIRA: YANGTOOLS-745
Change-Id: I2e35e3965c0a30a3d8368eeee45f5485a1765d29
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
void writeTo(@NonNull OutputStream out) throws IOException;
}
+ private static final int READ_BUFFER_SIZE = 8192;
+
FileState {
requireNonNull(path);
}
static @NonNull FileState ofFile(final Path file) throws IOException {
try (var cis = new CapturingInputStream(Files.newInputStream(file))) {
- cis.readAllBytes();
+ // Essentially cis.readAllBytes() except we do not need the actual bytes
+ final var bytes = new byte[READ_BUFFER_SIZE];
+ while (cis.readNBytes(bytes, 0, READ_BUFFER_SIZE) != 0) {
+ // Nothing else
+ }
return new FileState(file.toString(), cis.size(), cis.crc32c());
}
}