1.

How can we delete all files in a directory?(a) Files.delete(path)(b) Files.deleteDir()(c) Directory.delete()(d) Directory.delete(path)I have been asked this question in a job interview.My question is from File and Directory topic in division Autoboxing & Miscellaneous of Java

Answer»

The correct OPTION is (a) Files.delete(PATH)

Easy explanation: The delete(Path) method deletes the file or THROWS an EXCEPTION if the deletion FAILS. If file does not exist a NoSuchFileException is thrown.



Discussion

No Comment Found

Related InterviewSolutions