Java Utililty Methods Path Create nio

List of utility methods to do Path Create nio

Description

The list of methods to do Path Create nio are organized into topic(s).

Method

voidclearAndCreate(Path dir)
clear And Create
if (Files.exists(dir)) {
    deleteDirectory(dir);
Files.createDirectory(dir);
voidcreateACL(Path root, Path p, GroupPrincipal readOnly, GroupPrincipal readWrite)
create ACL
final AclFileAttributeView av = Files.getFileAttributeView(p, AclFileAttributeView.class,
        LinkOption.NOFOLLOW_LINKS);
if (av == null) {
    throw new UnsupportedOperationException("AclFileAttributeView for " + p);
final PosixFileAttributes attrs = Files.readAttributes(p, PosixFileAttributes.class,
        LinkOption.NOFOLLOW_LINKS);
List<AclEntry> acls = av.getAcl();
...
WritercreateAndGetOutputStream(String typename, String outputPath)
create And Get Output Stream
if (typename.indexOf('$') > 0) {
    System.out.println(typename);
    typename = typename.substring(0, typename.lastIndexOf('.')) + "."
            + typename.substring(typename.indexOf('$') + 1);
File file = new File(outputPath, typename.replace('.', File.separatorChar) + ".java");
file.getParentFile().mkdirs();
file.createNewFile();
...
BufferedReadercreateBufferedReader(Path path)
create Buffered Reader
BufferedReader reader = new BufferedReader(
        new InputStreamReader(new FileInputStream(path.toString()), "UTF-8"));
return reader;
MapcreateChecksums(final Path file, final Map functions)
create Checksums
if (functions.isEmpty()) {
    return Collections.emptyMap();
final Map<String, Hasher> hasherMap = new HashMap<>();
final Hasher[] hashers = new Hasher[functions.size()];
int i = 0;
for (final Map.Entry<String, HashFunction> entry : functions.entrySet()) {
    hashers[i] = entry.getValue().newHasher();
...
voidcreateClassWithDepsNextExtra(int index, Path dir)
create Class With Deps Next Extra
writeLinesToFile(dir.resolve("Deps" + index + CPP_HEADER_FILE_SUFFIX), "class Deps" + index + " {",
        "public:", "  static void printSth();", "  static void printSthElse();",
        "  static void callNext();", "};");
writeLinesToFile(dir.resolve("Deps" + index + CPP_FILE_SUFFIX), "#include <random>", "#include <iostream>",
        "#include <ctime>", "#include \"Deps" + (index + 1) + ".h\"", "using namespace std;", "",
        "class Deps" + index + " {", "public:", "  static void printSth() {", "    srand(time(NULL));",
        "    int n = rand();",
        "    cout << \"This is method(printSth) with random number(\" << n << \")\\n\";", "  }",
...
voidcreateDir(Path p)
create Dir
File file = p.toFile();
file.mkdir();
voidcreateDirectoriesIfRequired(@Nonnull Path path)
create Directories If Required
if (!exists(path)) {
    createDirectories(path);
PathcreateDirectory(final Path parent, final String folderName)
Creates a new directory with the given parent folder and folder name.
final File file = new File(parent.toFile(), folderName);
if (!file.exists()) {
    if (!file.mkdir()) {
        throw new RuntimeException(
                "Error while trying to create folder at " + parent + " with " + folderName + ".");
file.deleteOnExit();
...
PathcreateDirectory(Path parent, String name)
Create a directory (recursively)
Path path = null;
try {
    File directory = new File(parent.toFile(), name);
    if (!directory.exists()) {
        if (directory.mkdirs()) {
            path = directory.toPath();
    } else if (directory.isDirectory()) {
...