Check out example codes for "delete contents of folder java". It will help you in understanding the concepts better.

Code Example 1

String[]entries = index.list();
for(String s: entries){
    File currentFile = new File(index.getPath(),s);
    currentFile.delete();
}

Learn ReactJs, React Native from akashmittal.com