Tweaking a bit this code: https://stackoverflow.com/a/14676464/962475, I want to have a list of all my folders up to n levels.
public void listf(String directoryName, ArrayList<File> directories, int level, int maxLevel) {
    File directory = new File(directoryName);
    // get all the files from a directory
    File[] fList = directory.listFiles();
    System.out.println(directoryName);
    //testing where it failded
    for (File file : fList) {
        if (file.isDirectory()) {
            directories.add(file);
            if(level<maxLevel)
                listf(file.getAbsolutePath(), directories, level+1, maxLevel);
        }
    }
}
This code gives me an error through - "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"while trying to access "C:\Config.msi" - this is a windows protected folder that, when trying to access using file explorer gives an "access denied" error.
Frankly, I don't really need this folder in my list, but I can't find how to filter folders by system folders. Maybe by getattribute, but couldn't find an appropriate attribute.