Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

...