title: Create New Text Files with Different Names in Java
body: <p>Every time the code is executed I want a new Text File to be created.</p>
  
  <p>The Text File should be called Person1.</p>
  
  <p>Next time code is executed the Text File should be called Person2. </p>
  
  <p>Then again the Text File should be called Person3. etc, etc....</p>
  
  <p>At the moment, I'm able to create a Text File named "Person1" but can't create another Text File named "Person2".</p>
  
  <pre><code>private int fileNumber = 1;
  fileNumber = fileNumber++;
  
  public static void main(String[] args) {
          try {
              FileWriter fw = new FileWriter("Person" + fileNumber + ".txt");
              PrintWriter pw = new PrintWriter(fw);
  
              pw.println("Hello you created a text file");
  
              pw.close();
          }
          catch (IOException e)
          {
              System.out.println("Error!");
  
          }
  }
  </code></pre>