Access Denied Java FileWriter / FileInputStream
<p>My program downloads a websites source code, modifies it, creates the file, and then reuploads it through the FTP.  However, I receive the following error when trying to open the created file:</p>

<pre><code>java.io.FileNotFoundException: misc.html (Access is denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.&lt;init&gt;(Unknown Source)
at Manipulator.uploadSource(Manipulator.java:63)
at Start.addPicture(Start.java:130)
at Start$2.actionPerformed(Start.java:83)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
</code></pre>

<p>When I navigate to the folder directory and attempt to open "misc.html" with Notepad I receive Access is Denied.  My code is fairly simple:</p>

<pre><code>File f = new File(page.sourceFileName);
    try {
        FileWriter out = new FileWriter(f);
        out.write(page.source);
        out.close();
    } catch (IOException e) {
        e.printStackTrace();
    } InputStream  input = new FileInputStream(f);
</code></pre>

<p>This is the vital excerpt from my program.  I have copied this into a different test program and it works fine, I create a misc.html file and reopen it with both FileInputStream and manually.</p>

<p>I would be worried about Administrator rights but the Test program works fine when I run it RIGHT after the problem program.  I also have checked if the file exists and is a file with File methods and it is as well.  Is this a result of me not closing a previous Input/Output properly?  I've tried to check everything and I am fairly positive I close all streams as soon as they finish...</p>

<p>Help! :)</p>

<p>UPDATE:</p>

<p>If I comment out the FileInputStream code and just leave the FileWriter the File still is Access Denied.  If I remove the FileWriter code, no File is made (so it's certainly not overwriting anything).  The FileWriter code is the first time the file is made and no exception is thrown - but I still cannot manually open the file.</p>
