jborgers/PMD-jPinpoint-rules

Rule Request: AvoidLoadingAllFromFile

Closed this issue · 0 comments

Reading all bytes/lines from a file in memory is risky. You may get OutOfMemoryError, or get long gc pauses.
example:
byte[] fileBytes = Files.readAllBytes(Paths.get(path))

Especially with large files a problem.
Solution is to stream-through to the destination, see https://github.com/jborgers/PMD-jPinpoint-rules/blob/master/docs/JavaCodePerformance.md#isio03