code: public static void requireDirectory(File destination) throws IOException, IllegalArgumentException {
          if (destination.isFile()) {
              throw new IllegalArgumentException(destination + " exists and is a file, directory or path expected.");
          } else if (!destination.exists()) {
              destination.mkdirs();
          }
          if (!destination.canWrite()) {
              throw new IllegalArgumentException("Can not write to destination " + destination);
          }
      }
docs: Makes sure that the given {@link File} is either a writable directory, or that it does not exist and a directory
  can be created at its path.
  <br>
  Will throw an exception if the given {@link File} is actually an existing file, or the directory is not writable
  
  @param destination the directory which to ensure its existence for
  @throws IOException if an I/O error occurs e.g. when attempting to create the destination directory
  @throws IllegalArgumentException if the destination is an existing file, or the directory is not writable