Clean a spam

Report a typo

All spam messages should normally go to a special spam folder. Sometimes we need to clean it up. Consider the following method to clean a spam folder:

1  public void cleanSpam(String username) {
2      File spamDir = new File(username + File.separator + "spam");
3
4      if (spamDir.exists()) {
5          for (File msg : spamDir.listFiles()) {
6              msg.__;
7          }
8          spamDir.delete();
9      }
10 }

The method checks that ${username}/spam directory exists and deletes it with all of its content.

  • username directory is a home directory for a user account;
  • spam directory is a directory where spam messages go.

It is possible that the spam directory doesn't exist at the moment. After the method's completion spam directory should be completely removed.

Fill the gap in the 6th line to make the method work properly.

Enter a short text
___

Create a free account to access the full topic