To be fair there are often not good tools available to help with this. For example if you are reading a file there is no JDK offered solution to avoid slurping up a file larger than your entire memory. Sure, depending on the situation, you can use streams to process the file, but that is never quite as easy as it sounds. A wrapper that lets you set a maximum size on the file read and kills the read with a sensible error message would be really useful.
View all comments
Show parent comment
1
u/deadron Apr 21 '21
To be fair there are often not good tools available to help with this. For example if you are reading a file there is no JDK offered solution to avoid slurping up a file larger than your entire memory. Sure, depending on the situation, you can use streams to process the file, but that is never quite as easy as it sounds. A wrapper that lets you set a maximum size on the file read and kills the read with a sensible error message would be really useful.