code: public static File ensureDirectoryWriteable(File logDir) throws FileNotFoundException {
      try {
        FileUtils.forceMkdir(logDir);
      } catch(IOException e){
        log.debug("Failed to create directory " + logDir, e);
        throw new FileNotFoundException("Failed to create directory: " + logDir + " IOException: " + e.getMessage());
      }
      if(!logDir.canWrite()) {
        log.debug("Init param log dir cannot be used!");
        throw new FileNotFoundException("Directory is not writable: " + logDir);
      }
      return logDir;
    }
docs: Try's to create a directory and ensures that it is writable.
  @param logDir The File object to check.
  @return The File object passed in for chaining call to it. This value will never be null.
  @throws FileNotFoundException Thrown if logDir is null, exists, is not a directory, cannot be created, or cannot be written to.