@Override
 public FileChannel truncate(long newLength) throws IOException {
   if (newLength < size()) {
     data.touch(readOnly);
     pos = Math.min(pos, newLength);
     data.truncate(newLength);
   }
   return this;
 }
 @Override
 public int write(ByteBuffer src) throws IOException {
   int len = src.remaining();
   if (len == 0) {
     return 0;
   }
   data.touch(readOnly);
   pos = data.readWrite(pos, src, 0 /*because we start writing from src.position()*/, len, true);
   src.position(src.position() + len);
   return len;
 }