Not able to perform any operation on a file created by batch
<p>This is what I am trying to achieve:
Run a batch file from a JAVA program. The batch creates a new file in a specific folder, let's say folder 'A'. Once the new file is created, JAVA program moves the newly created file from folder 'A' to folder 'B'. </p>

<p>Following is the code snippet:</p>

<pre><code>// Run a batch that creates a file
String[] cmd = new String[]{"cmd", "/C", "start /min" + batchFilePath + batchFileName};
Process proc = Runtime.getRuntime().exec(cmd);  
proc.waitFor();


// Command in the batch file

dir c:\ &gt; C:\Chen_Med\EDICron\EDIOUT\test.edi
exit

// Move the file created by batch
boolean result2= ediOutFile.renameTo(new File(processedFolder, ediOutFile.getName()));
</code></pre>

<p>This is what happens when I run the above code:
New file gets created in folder 'A'. However, the newly created file is not moved to folder 'B'.</p>

<p>Analysis:</p>

<blockquote>
  <p>There is no syntactical issue in above code.
  I tried an alternative to moving the file. That is, read-write the file from folder 'A' to folder 'B' and then deleting the file from folder 'A'. New file is created in folder 'B', however, file is not deleted from folder 'B'.
  When I run another program that tries to move the file, after above program is executed, it works. That said, there seems to be an issue with Runtime holding the control over the file.</p>
</blockquote>

<p>Please help me with the solution. I have wasted my whole day trying to figure the solution :(</p>
