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.");
            }
        }
    }
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." ) ; } } }
Writes to ch until no remaining left or throws IOException
@param ch
@param bb
@throws IOException