code: public static void compareAndCheck(String[] list, String[] original,
        String nameNew, String nameOriginal, Boolean unique) throws IOException {
      if (list != null) {
        if (list.length != original.length) {
          throw new IOException(
              "unequal size " + nameNew + " and " + nameOriginal);
        }
        if (unique) {
          Set<String> set = new HashSet<>();
          for (int i = 0; i < list.length; i++) {
            set.add(list[i]);
          }
          if (set.size() < list.length) {
            throw new IOException("duplicate " + nameNew);
          }
        }
      }
    }
docs: Compare and check.
  
  @param list the list
  @param original the original
  @param nameNew the name new
  @param nameOriginal the name original
  @param unique the unique
  @throws IOException Signals that an I/O exception has occurred.