Example usage for java.nio.file Files createDirectories

List of usage examples for java.nio.file Files createDirectories

Introduction

In this page you can find the example usage for java.nio.file Files createDirectories.

Prototype

public static Path createDirectories(Path dir, FileAttribute<?>... attrs) throws IOException 

Source Link

Document

Creates a directory by creating all nonexistent parent directories first.

Usage

From source file:com.kamike.misc.FsUtils.java

public static void createDir(String dstPath) {
    Properties props = System.getProperties(); //    
    String osName = props.getProperty("os.name"); //???   
    Path newdir = FileSystems.getDefault().getPath(dstPath);

    boolean pathExists = Files.exists(newdir, new LinkOption[] { LinkOption.NOFOLLOW_LINKS });
    if (!pathExists) {
        Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxrwxrwx");
        FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
        try {/*ww w . j  a v  a 2s .  c om*/
            if (!osName.contains("Windows")) {
                Files.createDirectories(newdir, attr);
            } else {
                Files.createDirectories(newdir);
            }
        } catch (Exception e) {
            System.err.println(e);

        }
    }
}

From source file:org.apache.pulsar.io.file.TestFileGenerator.java

public TestFileGenerator(BlockingQueue<File> producedFiles, int numFiles, long delay, int numLines, String dir,
        String prefix, String suffix, FileAttribute<?>... attrs) throws IOException {
    this.numFiles = numFiles;
    this.delay = delay;
    this.numLines = numLines;
    this.producedFiles = producedFiles;
    this.prefix = prefix;
    this.suffix = suffix;
    this.attrs = attrs;
    tempDir = Files.createDirectories(Paths.get(dir), attrs);
}

From source file:com.collective.celos.ci.mode.TestTask.java

static File getTempDir() throws IOException {
    File celosCiDir = new File(System.getProperty("user.home"), CELOS_CI_DIR);
    File tempDir = new File(celosCiDir, UUID.randomUUID().toString());
    return Files.createDirectories(tempDir.toPath(), getTempDirAttributes()).toFile();
}

From source file:com.kamike.misc.FsUtils.java

public static void createDirectory(String dstPath) {

    Properties props = System.getProperties(); //    
    String osName = props.getProperty("os.name"); //???   
    Path newdir = FileSystems.getDefault().getPath(dstPath);

    boolean pathExists = Files.exists(newdir, new LinkOption[] { LinkOption.NOFOLLOW_LINKS });
    if (!pathExists) {
        Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxrwxrwx");
        FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
        try {/* w  w  w .j  a v  a  2 s  .  co  m*/
            if (!osName.contains("Windows")) {
                Files.createDirectories(newdir, attr);
            } else {
                Files.createDirectories(newdir);
            }
        } catch (Exception e) {
            System.err.println(e);

        }
    }
}

From source file:com.vns.pdf.impl.PdfDocument.java

private void setWorkingDir() throws IOException {
    ApplicationProperties.KEY.PdfDir.asString();
    workingDir = Paths.get(ApplicationProperties.KEY.PdfDir.asString());
    Files.createDirectories(workingDir, new FileAttribute[0]);
    pdfTempDir = Paths.get(ApplicationProperties.KEY.Workspace.asString(), "temp");
    if (!Files.exists(pdfTempDir, LinkOption.NOFOLLOW_LINKS)) {
        Files.createDirectories(pdfTempDir);
    }/*from  w w  w  . j  av  a2 s . co  m*/
    ImageIO.setCacheDirectory(pdfTempDir.toFile());
    ImageIO.setUseCache(true);
}