I am reading a set of files (~1.8 mil files, ~20KB each) into Strings (for further processing) using the following:
byte[] encoded = Files.readAllBytes(Paths.get(path));
return encoding.decode(ByteBuffer.wrap(encoded)).toString();
I am running into a strange problem that I don't understand. The first time that I run this process it takes about 10-15 seconds. On subsequent executions it takes about 1.5 seconds. If I try again in a few hours the same behavior happens. The first time it takes long and afterwards it runs very fast. This suggests some kind of caching (or something else), but I can't find an explanation for this behavior.
Any help would be appreciated. Thank you