я пытаюсь рекурсивно перечислить все файлы из системного корня, каталогов и отдельных файлов, код выполняется без каких-либо исключений, но когда код находит «Config.Msi» в качестве каталога, он дает мне ошибку в функции, которая выводит список и находит подкаталоги.
//Root path scan
for (File file : FilesInDisk) {
if (file.isFile()){
System.out.println("---------------------------------------------------------------------------------------------------------");
System.out.println("[File Detected] => [ " + file.getName()+" ]");
fileCache.add(fileIndex,file);
System.out.println("[ Absolute path added to files cache ] [Details] => "+file.getAbsolutePath());
fileIndex=fileIndex+1;
System.out.println("---------------------------------------------------------------------------------------------------------");
}
else
if (file.isDirectory()){
System.out.println("---------------------------------------------------------------------------------------------------------");
//Walk into directory and walk more while directories still exist then return and go on with next one
System.out.println("[Folder Detected] => [ " + file.getName()+" ]");
System.out.println("[ Absolute path added to files cache ] [Details] => "+file.getAbsolutePath());
subDirs(file);
folderIndex=folderIndex+1;
System.out.println("---------------------------------------------------------------------------------------------------------");
}
System.out.println("=> Files Scanned: " + fileIndex);
System.out.println("Scanning on progress...");
}
}
А это функция subDirs
//Look inside directories.
public void subDirs(File ifile){
File arrayDir[]=ifile.listFiles();
for (File arr :arrayDir){
System.out.println("===> " + arr);
}
}
[Folder Detected] => [ Config.Msi ]
[ Absolute path added to files cache ] [Details] => C:\Config.Msi
Exception in thread "main" java.lang.NullPointerException
at malwaredestroyer.MalwareDestroyer.subDirs(MalwareDestroyer.java:58)
at malwaredestroyer.MalwareDestroyer.walk(MalwareDestroyer.java:89)
at malwaredestroyer.MalwareDestroyer.main(MalwareDestroyer.java:100)
Это сообщение об ошибке, которое я получаю из консоли вывода,