title: producing some text file using a for loop in java?
body: <p>I am going to produce some text files(number of files is entered by user) using a for loop, but when the program runs only one file is produced because the file name doesn't change. I don't know how to change the names of file every time. my code is below which produces only one text file not as many as the user enters.</p>
  
  <pre><code>Scanner sc = new Scanner(System.in);
  int p1 = sc.nextInt();
  
          for (int i = 0; i &lt; p1; i++) {
              try {
              FileWriter f = new FileWriter("textfile.txt");
              f.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
  }
  </code></pre>