title: Delete a XML input file Java
body: <p>I am reading a XML file, process elements and write another XML file with the elements extracted form the input file.
  For this I am using the StAX cursor: I read elements with XMLStreamReader and write elements in another file using XMLStreamWriter.</p>
  
  <p>The reader:</p>
  
  <pre><code> XMLInputFactory inputFactory = XMLInputFactory.newInstance();
      XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new FileReader(inputFile));
  </code></pre>
  
  <p>The writer:</p>
  
  <pre><code>XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
  XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new FileOutputStream (outputFile),"UTF-8");
  </code></pre>
  
  <p>After I finish processing and writing the output file, I want to delete the file I read (the input file). For trhis I am using:</p>
  
  <pre><code>public void deleteInputFile(String inputFile) {
          File fileToDelete = new File(inputFile);
          if(fileToDelete.delete()){
              System.out.println(fileToDelete.getName() + " is deleted!");
          }else{
              System.out.println("Delete operation is failed.");
          }
      }
  </code></pre>
  
  <p>All program works fine, but the delete opretion fails. I get the response:</p>
  
  <blockquote>
    <p>Delete operation is failed.</p>
  </blockquote>
  
  <p>I think the reader close the input file after it reads it. </p>
  
  <p><strong>The question is, what showld I do to delete the input file after writing the file I need?</strong></p>