code: public static boolean deletePathIfEmpty(FileSystem fileSystem, Path path) throws IOException {
  		final FileStatus[] fileStatuses;
  
  		try {
  			fileStatuses = fileSystem.listStatus(path);
  		}
  		catch (FileNotFoundException e) {
  			// path already deleted
  			return true;
  		}
  		catch (Exception e) {
  			// could not access directory, cannot delete
  			return false;
  		}
  
  		// if there are no more files or if we couldn't list the file status try to delete the path
  		if (fileStatuses == null) {
  			// another indicator of "file not found"
  			return true;
  		}
  		else if (fileStatuses.length == 0) {
  			// attempt to delete the path (will fail and be ignored if the path now contains
  			// some files (possibly added concurrently))
  			return fileSystem.delete(path, false);
  		}
  		else {
  			return false;
  		}
  	}
docs: Deletes the path if it is empty. A path can only be empty if it is a directory which does
  not contain any other directories/files.
  
  @param fileSystem to use
  @param path to be deleted if empty
  @return true if the path could be deleted; otherwise false
  @throws IOException if the delete operation fails