code: public static ByteBuf toByteBuf(InputStream input) throws IOException {
          ByteBuf buf = Unpooled.buffer();
          int n = 0;
          do {
              n = buf.writeBytes(input, BLOCK_SIZE);
          } while (n > 0);
          return buf;
      }
docs: Reads an InputStream into a byte array.
  @param input the InputStream.
  @return a byte array representation of the InputStream.
  @throws IOException if an I/O exception of some sort happens while reading the InputStream.