title: Delete hdfs folder from java
body: <p>In a java app running on an edge node, I need to delete a hdfs folder, if it exists. I need to do that before running a mapreduce job (with spark) that output in the folder.</p>
  
  <p>I found I could use the method </p>
  
  <pre><code>org.apache.hadoop.fs.FileUtil.fullyDelete(new File(url))
  </code></pre>
  
  <p>However, I can only make it work with local folder (i.e. file url on the running computer). I tried to use something like:</p>
  
  <pre><code>url = "hdfs://hdfshost:port/the/folder/to/delete";
  </code></pre>
  
  <p>with <code>hdfs://hdfshost:port</code> being the hdfs namenode IPC. I use it for the mapreduce, so it is correct.
  However it doesn't do anything. </p>
  
  <p>So, what url should I use, or is there another method?</p>
  
  <p>Note: <a href="https://github.com/julien-diener/spark-csvconverter" rel="noreferrer">here</a> is the simple project in question.</p>