code: public static boolean correctOffsetAndLengthToWrite(byte[] b, int off, int len) {
          if (b == null) {
              throw new NullPointerException();
          } else if ((off < 0) || (off > b.length) || (len < 0)
                  || ((off + len) > b.length) || ((off + len) < 0)) {
              throw new IndexOutOfBoundsException();
          } else if (len == 0) {
              return false;
          }
          return true;
      }
docs: Security check mostly copied from {@link OutputStream#write(byte[], int, int)}.
  Ensures the parameter are valid.
  @param b the byte array to write to the array
  @param off the offset to write to the array
  @param len the len of the bytes to write to the array
  @return <code>true</code> if there are bytes to write, otherwise <code>false</code>
  @throws NullPointerException if the array is null
  @throws IndexOutOfBoundsException if the index is not correct