...
Code Block | ||
---|---|---|
| ||
void readData() { int bufferSize = 16 * 1024; byte zeroes = new byte[bufferSize]; ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize); try (FileChannel rdr = (new FileInputStream("file")).getChannel()) { while (rdr.read(buffer) > 0) { // Do something with the buffer buffer.clear(); buffer.put(zeroes); // overwrite buffer with zeroes buffer.clear(); } } catch (Throwable e) { // Handle error } } |
...
[API 2013] | Class ByteBuffer |
[Oracle 2013b] | Reading ASCII Passwords from an InputStream Example (Java Cryptography Architecture [JCA] Reference Guide) |
[Tutorials 2013] | I/O from the Command Line |
...