KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In response to my answer to a file-reading question , a commenter stated that FileInputStream.read(byte[]) is "not guaranteed to fill the buffer." File file = /* ... */ long len = file.length(); byte[] buffer = new byte[(int)len]; FileInputStream in = new FileInputStream(file); in.read(buffer); (The code assumes that the file length does not exceed 2GB) Apart from an IOException , what could cause the read method to not retrieve the entire file contents? EDIT: The idea of the code (and the goal of the OP of the question I answered) is to read the entire file into a chunk of memory in one swoop, that's why buffer_size = file_size .
Tags (comma-separated)
Save Edits
Cancel