i would like to know how to implement the FileNotFoundException in my code.

my code concatenate files from a Folder, it's working well even if there is no file.
So i want to throw a message something like 'There is no file in the folder"
If there is no files in C:\FileA
here is my code:

public class Concatenate
//FileNotFoundException   IOException
  static public void main(String arg[]) throws java.io.IOException

    PrintWriter pw = new PrintWriter(new FileOutputStream("C:/FileB/FileB.txt"));// directory where concatenated file are created

    File file = new File("C:/FileA");//directory where files are stored and deleted after concatenation
    File[] files = file.listFiles();
    for (int i = 0; i < files.length; i++)
      File currentFile = files[i];
      System.out.println("Processing " + currentFile.getPath() + "... ");
      BufferedReader br = new BufferedReader(new FileReader(currentFile));
      String line = br.readLine();
      while (line != null)
        line = br.readLine();
      if (!currentFile.delete())
        // Failed to delete file
        System.out.println("Failed to delete "+ currentFile.getName());
    System.out.println("All files have been concatenated into FileB.txt");

Thank you

This question has already been answered. Start a new discussion instead.