Java Path Create nio createRandomFolders(Path basePath, int numberOfFolders)

Here you can find the source of createRandomFolders(Path basePath, int numberOfFolders)

Description

create Random Folders

License

Open Source License

Declaration

public static List<Path> createRandomFolders(Path basePath, int numberOfFolders) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

public class Main {
    private static int FOLDER_NUMBER = 0;

    public static List<Path> createRandomFolders(Path basePath, int numberOfFolders) throws IOException {
        List<Path> folders = new ArrayList<>();
        for (int i = 0; i < numberOfFolders; ++i) {
            Path folder = createRandomFolder(basePath);
            folders.add(folder);/*from   w w  w. j  av a  2 s . c  o  m*/
        }
        return folders;
    }

    public static Path createRandomFolder(Path basePath) throws IOException {
        String folderName = "f" + FOLDER_NUMBER++;
        Path p = basePath.resolve(folderName);
        Files.createDirectory(p);
        return p;
    }
}

Related

  1. createPathOrNull(String pathString)
  2. createPathRelativizer(Path path, boolean doRelativize)
  3. createProperties(final Path directory, final Properties properties)
  4. createRandomClass(String className, Path dir)
  5. createRandomFolder(Path basePath)
  6. createRelativePath(File baseDirFile, File file)
  7. createSourceFile(Path path, String... lines)
  8. createSymbolicLink(String linkPathString, String targetPathString)
  9. createSymlink(Path realFileLocation, Path softLinkLocation)