3 ms·
You should never read() one byte at a time unless you like waiting. The C idiom is still true for Java: byte[] buf=new byte[4096]; // this matters while(true)
by RandyRanderson 9y ago
You should never read() one byte at a time unless you like waiting. The C idiom is still true for Java:
byte[] buf=new byte[4096]; // this matters
while(true) {
int num=in.read(buf,0,buf.length);
...
}
Also MemMapped files in Java have an int index so you can't really use them for large files without using another method as well.
Finally typically one has to parse the files to a string of a certain charset. This poses still more issues in terms of how you read files; esp multi and variable byte charsets.