code: public static File getDirectory(String path) {
          boolean log = false;
          File dir = new File(path);
          if (!dir.exists()) {
              log = true;
              try {
                  FileUtils.forceMkdir(dir);
              } catch (IOException e) {
                  throw new IllegalArgumentException("Unable to create new directory at path: " + path, e);
              }
          }
          String absPath = dir.getAbsolutePath();
          if (absPath.trim().length() == 0) {
              throw new IllegalArgumentException(path + " is empty");
          }
          if (!dir.isDirectory()) {
              throw new IllegalArgumentException(path + " is not a directory");
          }
          if (!dir.canRead()) {
              throw new IllegalArgumentException(path + " is not a readable directory");
          }
          if (log) {
              logger.info("Created directory: " + absPath);
          }
          return dir;
      }
docs: Retrieve the directory located at the given path. Checks that path indeed is a reabable
  directory. If this does not exist, create it (and log having done so).
  
  @param path directory(ies, can include parent directories) names, as forward slash ('/')
  separated String
  @return safe File object representing that path name
  @throws IllegalArgumentException If it is not a directory, or it is not readable