docs: public static void writeAll(WritableByteChannel ch, ByteBuffer bb) throws IOException
      {
          int count = 0;
          while (bb.hasRemaining())
          {
              int rc = ch.write(bb);
              if (rc == 0)
              {
                  count++;
              }
              if (count > 100)
              {
                  throw new IOException("Couldn't write all.");
              }
          }
      }