PreparedFoldersMapFileSystem - ViiSE/papka GitHub Wiki

PreparedFoldersMapFileSystem

PreparedFoldersMapFileSystem - Prepares folders as Map<String, Folder<File>>, where key is full folder name, and value is the folder with files.

Constructors

public PreparedFoldersMapFileSystem(PreparedFolders<Map<String, List<File>>> prepFolders)

PreparedFolders<Map<String, List<File>>> prepFolders - Prepares folders as Map<String, List<File>>, where key is full folder name, and value is the list of folder files.

Example

List<File> files = new ArrayList<>();
files.add("/home/file1.txt");
files.add("/home/file2.txt");
files.add("/home/root1.txt");
files.add("/home/root2.txt");
files.add("/home/root3.txt");
files.add("/home/folder1/file1.txt");
files.add("/home/folder1/file2.txt");
files.add("/home/folder2/file1.txt");

PreparedFolders<Map<String, Folder<File>>> prepFolders = new PreparedFoldersMapFileSystem(
         new PreparedFoldersMapFilesRaw(files)
);

Map<String, Folder<File>> mapFile = prepFolders.preparation();
mapFile.forEach((fullFolderName, prFolder) -> {
        System.out.println(fullFolderName);
        Folder<File> folder = prFolder.fullName();
        prFolder.files().forEach(file -> System.out.println("\t" + file.getName()));
    }
);
Output:
/

/home
    file1.txt
    file2.txt
    root1.txt
    root2.txt
    root3.txt
/home/folder1
    file1.txt
    file2.txt
/home/folder2
    file1.txt

Links

PreparedFolders - implementable interface.

⚠️ **GitHub.com Fallback** ⚠️