...
Code Block | ||
---|---|---|
| ||
void readData() { int bufferSize = 16 * 1024; ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024bufferSize); try (FileChannel rdr = (new FileInputStream("file")).getChannel()) { while (rdr.read(buffer) > 0) { // Do something with the buffer buffer.put(new byte[bufferSize]); // overwrite buffer with zeroes buffer.clear(); } } catch (Throwable e) { // Handle error } } |
...