PreparedFoldersMapFile - ViiSE/papka GitHub Wiki

PreparedFoldersMapFile

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

Constructors

public PreparedFoldersMapFile(PreparedFolders<Map<String, List<String>>> prepFolders)

PreparedFolders<Map<String, List<String>>> prepFolders - prepared folders, where key is full folder name, and value is list of full filename of this folder.
public PreparedFoldersMapFile(
            PreparedFolders<Map<String, List<String>>> prepFolders,
            boolean excludeNonExisting)


PreparedFolders<Map<String, List<String>>> prepFolders - prepared folders, where key is full folder name, and value is list of full filename of this folder;
boolean excludeNonExisting - exclude non-existent files or not (default - false)?

Example

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

PreparedFolders<Map<String, List<String>>> prepFolders = new PreparedFoldersMapRaw(rawFiles);

Map<String, Folder<File>> mapFile = new PreparedFoldersMapFile(prepFolders).preparation();
mapFile.forEach((fullFolderName, prepFiles) -> {
        System.out.println(fullFolderName); 
        prepFiles.forEach(file -> System.out.println("\t" + file.getName())); 
    }
);
Output:

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

Links

PreparedFolders - implementable interface.

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