Home » JAVA Programming » Files and I/O » Question
  1. How can we delete all files in a directory?
    1. Directory.delete(path)
    2. Files.delete(path)
    3. Directory.delete()
    4. Files.deleteDir()
    5. None of these
Correct Option: B

The delete(Path) method deletes the file or throws an exception if the deletion fails. If file does not exist a NoSuchFileException is thrown.



Your comments will be displayed only after manual approval.