All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.ibole.infrastructure.common.utils.TemporaryDirectory Maven / Gradle / Ivy

The newest version!
package com.github.ibole.infrastructure.common.utils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

/*********************************************************************************************
 * .
 * 
 * 
 * 

* Copyright 2016, iBole Inc. All rights reserved. * *

*

*********************************************************************************************/ /** * Helper to ensure temporary directory is sane. * */ public class TemporaryDirectory { private TemporaryDirectory() { // empty } // NOTE: Do not reset the system property, we can not ensure this value will be used public static File get() throws IOException { String location = System.getProperty("java.io.tmpdir", "tmp"); File dir = new File(location).getCanonicalFile(); DirectoryHelper.mkdir(dir.toPath()); // ensure we can create temporary files in this directory Path file = Files.createTempFile("nexus-tmpcheck", ".tmp"); Files.delete(file); return dir; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy