Example usage for java.nio.file Files createTempDirectory

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

Introduction

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

Prototype

public static Path createTempDirectory(String prefix, FileAttribute<?>... attrs) throws IOException 

Source Link

Document

Creates a new directory in the default temporary-file directory, using the given prefix to generate its name.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {

    Path rootDirectory = FileSystems.getDefault().getPath("C:/home/docs");

    Path tempDirectory = Files.createTempDirectory(rootDirectory, "");
    System.out.println("Temporary directory created successfully!");
    String dirPath = tempDirectory.toString();
    System.out.println(dirPath);/*from ww  w. ja  v a 2  s  .c o m*/
    Path tempFile = Files.createTempFile(tempDirectory, "", "");
    System.out.println("Temporary file created successfully!");
    String filePath = tempFile.toString();
    System.out.println(filePath);
}

From source file:Main.java

public static void main(String[] args) throws IOException {

    final Path basedir = FileSystems.getDefault().getPath("C:/tutorial/tmp/");
    final String tmp_dir_prefix = "Swing_";

    final Path tmp_dir = Files.createTempDirectory(basedir, tmp_dir_prefix);

}

From source file:de.tudarmstadt.ukp.dkpro.core.flextag.model.InstallAsMavenArtifact.java

public static void main(String[] args) throws IOException {

    String modelLocation = "PathToTheFolderContainingTheModelFiles";

    String version = "VersionId"; //i.e. a data YYYYMMDD
    String language = "en";
    String variant = "YourModelNameHere";

    String modelencoding = "encoding"; // i.e. utf-8
    String postagset = "tagset"; //en=ptb, de=stts, etc

    String targetName = language + "-" + variant;
    String workingDirectory = Files.createTempDirectory("installModel", new FileAttribute<?>[] {})
            .toAbsolutePath().toString();

    String preparedScript = prepareBuildScript(modelLocation, groupId, artifactId, version, tool, language,
            variant, targetName, workingDirectory, modelencoding, postagset);

    File script = new File(workingDirectory + "/build.xml");
    FileUtils.writeStringToFile(script, preparedScript);

    runAntToInstall(script);/*from w  ww  .  j a va  2  s  .c om*/

}

From source file:de.tudarmstadt.ukp.dkpro.core.flextag.InstallAsMavenArtifact.java

public static void main(String[] args) throws IOException {

    String modelLocation = "/Users/toobee/Desktop/shrdTaskModel";

    String version = "20160330"; //i.e. a data YYYYMMDD
    String language = "de";
    String variant = "empiri";

    String modelencoding = "utf-8"; // i.e. utf-8
    String postagset = "stts"; //en=ptb, de=stts, etc

    String targetName = language + "-" + variant;
    String workingDirectory = Files.createTempDirectory("installModel", new FileAttribute<?>[] {})
            .toAbsolutePath().toString();

    String preparedScript = prepareBuildScript(modelLocation, groupId, artifactId, version, tool, language,
            variant, targetName, workingDirectory, modelencoding, postagset);

    File script = new File(workingDirectory + "/build.xml");
    FileUtils.writeStringToFile(script, preparedScript);

    runAntToInstall(script);//  ww w  . ja  v  a  2s .c  om

}

From source file:io.undertow.server.handlers.file.ContentEncodedResourceTestCase.java

@BeforeClass
public static void setup() throws IOException {

    tmpDir = Files.createTempDirectory(Paths.get(System.getProperty("java.io.tmpdir")), DIR_NAME);

    final PathResourceManager resourceManager = new PathResourceManager(tmpDir, 10485760);
    DefaultServer/*  w w w .ja v  a  2 s . c o  m*/
            .setRootHandler(
                    new ResourceHandler(resourceManager)
                            .setContentEncodedResourceManager(
                                    new ContentEncodedResourceManager(tmpDir,
                                            new CachingResourceManager(100, 10000, null, resourceManager, -1),
                                            new ContentEncodingRepository().addEncodingHandler("deflate",
                                                    new DeflateEncodingProvider(), 50, null),
                                            0, 100000, null)));
}

From source file:at.makubi.maven.plugin.avrohugger.AvrohuggerGeneratorTest.java

@Before
public void setUp() throws Exception {
    avrohuggerGenerator = new AvrohuggerGenerator();
    outputDirectory = Files.createTempDirectory(Paths.get(getBasedir()).resolve("target"),
            AvrohuggerGeneratorTest.class.getCanonicalName());
}

From source file:fr.inria.atlanmod.neoemf.extension.Workspace.java

public File newFile(String prefix) throws IOException {
    Path createdFolder = Files.createTempDirectory(temporaryFolder.toPath(), prefix);
    Files.deleteIfExists(createdFolder);
    return createdFolder.toFile();
}

From source file:org.bonitasoft.web.designer.controller.utils.Unzipper.java

public Path unzipInTempDir(InputStream is, String tempDirPrefix) throws IOException {
    Path tempDirectory = Files.createTempDirectory(temporaryZipPath, tempDirPrefix);
    Path zipFile = writeInDir(is, tempDirectory);
    try {//from w  ww .  j a v  a2 s .co m
        ZipUtil.unpack(zipFile.toFile(), tempDirectory.toFile());
    } catch (org.zeroturnaround.zip.ZipException e) {
        throw new ZipException(e.getMessage());
    } finally {
        FileUtils.deleteQuietly(zipFile.toFile());
    }
    return tempDirectory;
}

From source file:net.certiv.antlr.project.util.Utils.java

/**
 * Creates a new, unique directory, with the given prefix, in the system temp directory.
 * /*from w ww  .jav  a  2s  .  co m*/
 * @return a File representing the new directory
 * @throws IOException
 */
public static File createTmpDir() throws IOException {
    Path p = null;
    if (Strings.pathSepStr == Strings.STD_SEPARATOR) {
        Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-x---");
        FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
        p = Files.createTempDirectory("ReGen", attr);
    } else {
        p = Files.createTempDirectory("ReGen");
    }
    return p.toFile();
}

From source file:org.apache.tika.eval.ComparerBatchTest.java

@BeforeClass
public static void setUp() throws Exception {

    File inputRoot = new File(ComparerBatchTest.class.getResource("/test-dirs").toURI());
    dbDir = Files.createTempDirectory(inputRoot.toPath(), "tika-test-db-dir-");
    Map<String, String> args = new HashMap<>();
    Path db = FileSystems.getDefault().getPath(dbDir.toString(), "comparisons_test");
    args.put("-db", db.toString());

    //for debugging, you can use this to select only one file pair to load
    //args.put("-includeFilePat", "file8.*");
    /*/* w ww .  j  a  v  a  2 s  .  c om*/
            BatchProcessTestExecutor ex = new BatchProcessTestExecutor(COMPARER_PROCESS_CLASS, args,
        "/tika-batch-comparison-eval-config.xml");
            StreamStrings streamStrings = ex.execute();
            System.out.println(streamStrings.getErrString());
            System.out.println(streamStrings.getOutString());
            H2Util dbUtil = new H2Util(db);
            conn = dbUtil.getConnection();*/
}