code: public static CountingWritableByteChannel from(File file) throws IOException {
          RandomAccessFile raf = new RandomAccessFile(file, "rw");
          raf.setLength(0);
          return new CountingWritableByteChannel(raf.getChannel());
      }
docs: Static factory method to create a {@link CountingWritableByteChannel} from an existing {@link File}. If the file already exists its content is purged.
  
  @param file
  @return the newly created {@link CountingWritableByteChannel}
  @throws IOException
  @see RandomAccessFile#RandomAccessFile(File, String)