I am trying to delete all files in a folder:-
import java.io.*;
public class AddService {
public static void main(String args[]){
File folder=
You have not given the full path for the folder. Also note to use forward slash.
try{
File folder=new File("C:/xxxx/xxxx/xxxx/inputs");
File[] listOfFiles=folder.listFiles();
for(File file:listOfFiles){
if(file.delete())
System.out.println("File deleted");
else
System.out.println("File not deleted");
}
}
catch(Exception e)
{
System.out.println(e.printStackTrace());
}
Always use try-catch for code that contains methods which throws Exceptions.