DataOutputStream and FileOutputStream locking file after finish?
<p>I have:</p>

<pre><code>static DataOutputStream outs;
static FileOutputStream fout;


  public static void main(String[] args) throws IOException {
      int numTasks;
      int numThreads;

      fout = new FileOutputStream("file.csv");

//Multithreaded method call where file is written to
new PrintStream(fout).println(Duration + ",");


//Keep getting error here
    outs.close();


    fout.flush();
    fout.close();

    System.in.read();
    System.exit(0);
  }
</code></pre>

<p>I want to close the file but it throws an error. Could someone please help?</p>
