Trying to delete files after concatenation with java
<p>here is a code to concatenate all files from a folder.
it works well but i modified it to delete files after concatenation and this function is not working coze i don't know how to declare in main method</p>

<p>Any help will be appreciated thank you very much.</p>

<pre><code>import java.io.*;
import java.io.File.*;

public class ConcatenatedFiles {

  static public void main(String arg[]) throws java.io.IOException {
    PrintWriter pw = new PrintWriter(new FileOutputStream("C:/Concatenated-file/concat.txt"));
    File file = new File("C:/Target");
    File[] files = file.listFiles();
    for (int i = 0; i &lt; files.length; i++) {
      System.out.println("Processing " + files[i].getPath() + "... ");
      BufferedReader br = new BufferedReader(new FileReader(files[i]
                      .getPath()));
      String line = br.readLine();
      while (line != null) {
        pw.println(line);
        line = br.readLine();
      }
      br.close();
    }
    pw.close();
    System.out.println("All files have been concatenated into concat.txt");

     File directory = new File("C:/Target");

    // Get all files in directory
    File[] files = directory.listFiles();
    for (File file : files)
    {
       // Delete each file
       if (!file.delete())
       {
         // Failed to delete file
         System.out.println("Failed to delete "+file);
       }
    }
  }
}
</code></pre>
