code: public static String toStringBinary(ByteBuffer buf) {
      if (buf == null) {
        return "null";
      }
      return toStringBinary(buf.array(), buf.arrayOffset(), buf.limit());
    }
docs: Converts the given byte buffer, from its array offset to its limit, to
  a string. The position and the mark are ignored.
  
  @param buf a byte buffer
  @return a string representation of the buffer's binary contents