Unable to delete a file in Java - Cannot figure out what I am missing
<p>I tried this code outside of my application and it works great, but I cannot for the life of me figure out why this will not delete the inputFile and rename the tempFile.</p>

<pre><code>    private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {                                      
File inputFile = new File("c:\\test.csv");
File tempFile = new File("c:\\temp.csv");
    try
    {
        BufferedReader reader = new BufferedReader(new FileReader(inputFile));
        BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));

        String lineToRemove = tf_custID.getText() + "," + tf_custName.getText() + "," + tf_contactName.getText() + "," + tf_lastContact.getText() + "," + tf_phoneNumber.getText() + "," + tf_shippingAddress.getText() + "," + tf_shippingAddress2.getText() + "," + tf_City.getText() + "," + cb_State.getSelectedItem().toString() + "," + tf_Zipcode.getText() + ","; 
        String currentLine;

        while((currentLine = reader.readLine()) != null) 
        {
            // trim newline when comparing with lineToRemove
            String trimmedLine = currentLine.trim();
            //System.err.println(trimmedLine);
            //System.err.println(lineToRemove);
            if(trimmedLine.equals(lineToRemove)) continue;
            writer.write(currentLine);
            writer.write("\n");                
        }


        reader.close();            
        writer.close();

        } 
    catch (FileNotFoundException e)
    {
        e.printStackTrace();
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }


    if(inputFile.delete())
    {
        System.out.println("** Input File Deleted Successfully, renaming temporary file. **");
        boolean successful = tempFile.renameTo(inputFile);
        if(successful)
        {
            System.out.println("** Temporary File Renamed Successfully");
        }
        else
        {
            System.err.println("** Temporary File Rename Failed");
        }
    }
    else
    {
        System.err.println("** Unable to Delete Input File **");            
    }

} 
</code></pre>

<p>Thanks in advance, I am just stuck.</p>
