Example usage for java.io File mkdir

List of usage examples for java.io File mkdir

Introduction

In this page you can find the example usage for java.io File mkdir.

Prototype

public boolean mkdir() 

Source Link

Document

Creates the directory named by this abstract pathname.

Usage

From source file:com.continuent.tungsten.common.commands.DirectoryCommands.java

/**
 * Creates a directory//www .j  a v a2 s  .  c om
 * 
 * @param path the path to create
 * @return true if the directory was created
 */
public static boolean mkdir(String path) {
    File f = new File(path);
    return f.mkdir();
}

From source file:brut.util.OS.java

public static File createTempDirectory() throws BrutException {
    try {/*  w  ww .java 2 s.c o  m*/
        File tmp = File.createTempFile("BRUT", null);
        if (!tmp.delete()) {
            throw new BrutException("Could not delete tmp file: " + tmp.getAbsolutePath());
        }
        if (!tmp.mkdir()) {
            throw new BrutException("Could not create tmp dir: " + tmp.getAbsolutePath());
        }
        return tmp;
    } catch (IOException ex) {
        throw new BrutException("Could not create tmp dir", ex);
    }
}

From source file:msec.org.TarUtil.java

private static void fileProber(File dirFile) {

    File parentFile = dirFile.getParentFile();
    if (!parentFile.exists()) {

        // // w  w  w.j av a  2 s.c o m
        fileProber(parentFile);

        parentFile.mkdir();
    }

}

From source file:uploadProcess.java

public static boolean decrypt(File inputFolder, String fileName, String patientID) {
    try {/*from w w w.j av  a  2s.c om*/
        //Download File from Cloud..
        DropboxUpload download = new DropboxUpload();
        download.downloadFile(fileName, StoragePath.getDropboxDir() + patientID, inputFolder);

        String ukey = GetKey.getPatientKey(patientID);
        File inputFile = new File(inputFolder.getAbsolutePath() + File.separator + fileName);
        FileInputStream fis = new FileInputStream(inputFile);
        File outputFolder = new File(inputFolder.getAbsolutePath() + File.separator + "temp");
        if (!outputFolder.exists()) {
            outputFolder.mkdir();
        }
        FileOutputStream fos = new FileOutputStream(outputFolder.getAbsolutePath() + File.separator + fileName);
        byte[] k = ukey.getBytes();
        SecretKeySpec key = new SecretKeySpec(k, "AES");
        Cipher enc = Cipher.getInstance("AES");
        enc.init(Cipher.DECRYPT_MODE, key);
        CipherOutputStream cos = new CipherOutputStream(fos, enc);
        byte[] buf = new byte[1024];
        int read;
        while ((read = fis.read(buf)) != -1) {
            cos.write(buf, 0, read);
        }
        fis.close();
        fos.flush();
        cos.close();
        return true;
    } catch (Exception e) {
        System.out.println("Error: " + e);
    }
    return false;
}

From source file:fr.inria.eventcloud.deployment.cli.launchers.EventCloudsManagementServiceDeployer.java

private static void downloadResources(String resourcesUrl, boolean activateLoggers) throws IOException {
    resourcesDirPath = System.getProperty("java.io.tmpdir") + File.separator + "eventcloud-resources";

    File tmpResourcesDir = new File(resourcesDirPath);
    tmpResourcesDir.mkdir();

    FileUtils.copyURLToFile(new URL(resourcesUrl + "proactive.security.policy"),
            new File(tmpResourcesDir, "proactive.security.policy"));

    if (activateLoggers) {
        FileUtils.copyURLToFile(new URL(resourcesUrl + "log4j-console.properties"),
                new File(tmpResourcesDir, "log4j-console.properties"));

        FileUtils.copyURLToFile(new URL(resourcesUrl + "logback-console.xml"),
                new File(tmpResourcesDir, "logback-console.xml"));
    } else {/*from w w  w  . jav a 2  s  .c  o  m*/
        FileUtils.copyURLToFile(new URL(resourcesUrl + "log4j-inactive.properties"),
                new File(tmpResourcesDir, "log4j-inactive.properties"));

        FileUtils.copyURLToFile(new URL(resourcesUrl + "logback-inactive.xml"),
                new File(tmpResourcesDir, "logback-inactive.xml"));
    }

    FileUtils.copyURLToFile(new URL(resourcesUrl + "eventcloud.properties"),
            new File(tmpResourcesDir, "eventcloud.properties"));
    List<String> eventCloudProperties = FileUtils
            .readLines(new File(resourcesDirPath + File.separator + "eventcloud.properties"));
    for (String property : eventCloudProperties) {
        if (property.startsWith(EventCloudProperties.REPOSITORIES_PATH.getName() + "=")) {
            repositoriesDirPath = property.substring(property.indexOf('=') + 1);
        }
    }
}

From source file:musite.MusiteInit.java

private static void initializeFolders() {
    File modelDirFile = new File(MODEL_DIR);
    if (!modelDirFile.exists()) {
        if (!modelDirFile.mkdir()) {
            //TODO: error processing
        }/*from  w w w .  ja va2s.  c om*/
    }

    File propsDirFile = new File(PROPS_DIR);
    if (!propsDirFile.exists()) {
        if (!propsDirFile.mkdir()) {
            //TODO: error processing
        }
    }

    File tmpDirFile = new File(TMP_DIR);
    if (!tmpDirFile.exists()) {
        if (!tmpDirFile.mkdir()) {
            //TODO: error processing
        }
    }
}

From source file:edu.uci.ics.hyracks.tests.integration.AbstractMultiNCIntegrationTest.java

@BeforeClass
public static void init() throws Exception {
    CCConfig ccConfig = new CCConfig();
    ccConfig.clientNetIpAddress = "127.0.0.1";
    ccConfig.clientNetPort = 39000;//  w w w .  ja  v  a 2  s  . c  o  m
    ccConfig.clusterNetIpAddress = "127.0.0.1";
    ccConfig.clusterNetPort = 39001;
    ccConfig.profileDumpPeriod = 10000;
    File outDir = new File("target" + File.separator + "ClusterController");
    outDir.mkdirs();
    File ccRoot = File.createTempFile(AbstractMultiNCIntegrationTest.class.getName(), ".data", outDir);
    ccRoot.delete();
    ccRoot.mkdir();
    ccConfig.ccRoot = ccRoot.getAbsolutePath();
    cc = new ClusterControllerService(ccConfig);
    cc.start();

    asterixNCs = new NodeControllerService[ASTERIX_IDS.length];
    for (int i = 0; i < ASTERIX_IDS.length; i++) {
        NCConfig ncConfig = new NCConfig();
        ncConfig.ccHost = "localhost";
        ncConfig.ccPort = 39001;
        ncConfig.clusterNetIPAddress = "127.0.0.1";
        ncConfig.dataIPAddress = "127.0.0.1";
        ncConfig.resultIPAddress = "127.0.0.1";
        ncConfig.nodeId = ASTERIX_IDS[i];
        asterixNCs[i] = new NodeControllerService(ncConfig);
        asterixNCs[i].start();
    }

    hcc = new HyracksConnection(ccConfig.clientNetIpAddress, ccConfig.clientNetPort);
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Starting CC in " + ccRoot.getAbsolutePath());
    }
}

From source file:IO.Directories.java

/**
 * Create directory for the given directory path
 *
 * @param directoryPath path of the destination directory to create
 * @return File which represent the created directory
 *//* w ww .j a v  a  2 s.  c  om*/
public static File CreateDirectory(String directoryPath) {
    File destinationDirectory = new File(directoryPath);
    boolean directoryCreated = false;
    //Create destination folder if not exist
    if (!destinationDirectory.exists()) {
        directoryCreated = destinationDirectory.mkdir();
        if (!directoryCreated) {
            Console.PrintException(String.format("Error creating directory: %s", directoryPath), null);
        }
    }
    return destinationDirectory;
}

From source file:com.uniteddev.Unity.Downloader.java

public static void folder(String dir, String dirname) {
    File folder = new File(dir);
    if (!folder.exists()) {
        folder.mkdir();
        Login.progressText.setText("Created directory: " + dirname);
        System.out.println("Created directory: " + dirname);
    }/*from  www  . j a v a  2s  .  c o  m*/
}

From source file:edu.tum.cs.ias.knowrob.utils.ResourceRetriever.java

/**
 * Creates a temporary directory (normally in the /tmp folder)
 * /*from  ww  w  .j  a  v a2  s  .  c  o m*/
 * @return File with path to created dir
 */
public static String createTempDirectory() {

    String tmpDir = System.getProperty("java.io.tmpdir");

    File temp = new File(tmpDir, "temp" + Long.toString(System.nanoTime()));

    if (!(temp.mkdir())) {
        System.err.println("Could not create temp directory: " + temp.getAbsolutePath());
    }

    return temp.getAbsolutePath();
}