Create files with similar names using Java without overwriting existing file
<p>I was wondering if it is possible to create multiple files with similar names, without overwriting the current file.</p>

<p>for example: 
if I have a file: xyz.txt
next time when i create it should be : xyz(1).txt </p>

<pre><code>try {
  File makefile = new File("output.txt");
  FileWriter fwrite = new FileWriter(makefile);
  fwrite.write("example file");
  fwrite.flush();
  fwrite.close();
} catch (IOException e) {
  e.printStackTrace();
}
</code></pre>

<p>so if I re-run this program my current file should not be overwritten. I have already tried and if condition with a flag variable to add number as prefix to the file name. </p>

<p>I want to know if there are any Java commands to avoid overwriting an existing file. </p>
