PreparedFoldersMapFilesRaw - ViiSE/papka GitHub Wiki

PreparedFoldersMapFilesRaw

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

Constructors

public PreparedFoldersMapFilesRaw(List<File> files)

List<File> files - List of files.
public PreparedFoldersMapFilesRaw(FoldersFile<String, String> foldersFile, List<File> files)


FoldersFile<String, String> foldersFile - folders file to form a list of folders from file names (default - FoldersFileName);
List<File> files - List of files.
public PreparedFoldersMapFilesRaw(FoldersFile<String, String> foldersFile, Separator separator, List<File> files)


FoldersFile<String, String> foldersFile - folders file to form a list of folders from file names (default - FoldersFileName);
Separator - separator of folders path and filenames (default - SeparatorUnix);
List<File> files - List of 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, List<File>>> prepFolders = new PreparedFoldersMapFilesRaw(files);

Map<String, List<File>> mapFile = 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.

FoldersFileName - default value constructor.

SeparatorUnix - default value constructor.

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