void writeFully(ByteBuffer data) throws IOException {
  while (data.hasRemaining()) {
    output.write(data);
  }
}

void writeFully ( ByteBuffer data ) throws IOException { while ( data . hasRemaining ( ) ) { output . write ( data ) ; } }
write entire data buffer to channel .
