Reputation: 1601
I have a program which reads data from an InputStream until a null is encountered. However, the program seems to not obtain all available data. Is it possible that a null is presented due to memory issues prematurely? I get not memory error but I do get files of different sizes and a much larger file was obtained when a change was made that may have freed memory. My plan is to run Java with options that give it much more memory.
Code:
while ((inputStr = streamReader.readLine()) != null){
doStuff();
}
Upvotes: 1
Views: 68
Reputation: 1601
The problem in fact was a disk space issue that caused the file to close (when caught that was part of cleanup) -- no null was encountered. The disk space error did not show up because the write to a log file could not complete. Thanks for the "barking up the wrong tree" comment because indeed I was. I should add that this was complicated by the code running on Amazon Web Services.
I am sorry if I did not give enough info to the posters but as I said, the input was useful.
Upvotes: 0
Reputation: 310979
Could memory issues in Java cause a
BufferedReader
to return null prematurely?
No. You would get an OutOfMemoryError,
not a premature null.
Upvotes: 2