Wie nutze ich List<List<String>>

Allrounder93

Aktives Mitglied
Hey,

ich würde gerne List<List<String>> nutzen und zwar wie folgt:

Ich durchsuche eine Verzeichnis (path) nach Dateien (files).
Sobald eine Datei (files) gefunden wird soll diese in zweiten List-Element gespeichert werden und im ersten Element, das Unterverzeichnis (Path).

C:
-Programme
--a.log
--b.log
--c.log
-System
--a.log
--b.log
-a.log
-b.log

Als List<List<String>> dann:
c:programme | a.log,b.log,c.log
c:System | a.log,b.log
c: | a.log,b.log

Mein Code bisher
Java:
	private static List<List<String>> AllPic;
	private static List<List<String>> AllMov;

    public static void find(File path) {
        if(path.exists() == true) {
            File[] files = path.listFiles();
            if(files != null){
                for(int i1 = 0; files.length <= i1; i1++) {
                	loops:
                	if(files[i1].isDirectory()) findPicMov(files[i1]);
                    else if(files[i1].isFile()) {
                        String name = files[i1].getName();
                        for(int pic = 0; Menu.getterPicFormat().length <= pic; pic++) {
                        	if (name.endsWith("." + Menu.getterAllPictureFormat()[pic])==true){
                        		AllPic.add(path).add(files[i1]);
                        		break loops;
                        	}
                        }
                        for(int movi = 0; Menu.getterMoviFormat().length <= movi; movi++) {
                        	...
 
                        }
                    }
                }
            }
        }
    }
}
 
Zuletzt bearbeitet:

Gucky

Top Contributor
Und was ist nun dein Problem?
Auf Elemente zugreifen geht entweder mit list.get(1).get(1); Oder mit einer verschachtelten for (each) Schleife.
 

Gucky

Top Contributor
Was mir noch aufgefallen ist:
Ein einzelnes
Code:
break;
reicht. Du musst keine Marke setzen.
 


Schreibe deine Antwort... und nutze den </> Button, wenn du Code posten möchtest...

Ähnliche Java Themen

Neue Themen


Oben