im creating a program that will compile java files, at the moment i have the program compiling numerous files at a time in one particular folder. but what i want it to do is to compile all the files in a folder structure given a folder to start (eg. if given the following address C:/files_to_be_compiled
, can you search all the folders within this folder to get a list of all the .class files). I have this code that is getting all the .class
files from a single folder but i need to expand this to get all the .class
files from all the rest of the folders in that folder given
String files;
File folder = new File("C:/files_to_compile");
File[] listOfFiles = folder.listFiles();
{
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
files = listOfFiles[i].getName();
if (files.endsWith(".class") || files.endsWith(".CLASS")) {
System.out.println(files);
}
}
}
}
how would i extend the code above get all the .class files from within all the folders in a given folder?