code: public int setBytes(int index, InputStream in, int length)
              throws IOException
      {
          checkIndexLength(index, length);
          byte[] bytes = new byte[4096];
          int remaining = length;
          while (remaining > 0) {
              int bytesRead = in.read(bytes, 0, Math.min(bytes.length, remaining));
              if (bytesRead < 0) {
                  // if we didn't read anything return -1
                  if (remaining == length) {
                      return -1;
                  }
                  break;
              }
              copyMemory(bytes, SizeOf.ARRAY_BYTE_BASE_OFFSET, base, address + index, bytesRead);
              remaining -= bytesRead;
              index += bytesRead;
          }
          return length - remaining;
      }
docs: Transfers data from the specified input stream into this slice starting at
  the specified absolute {@code index}.