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:net.itransformers.idiscover.v2.core.listeners.GraphmlFileLogGroovyDiscoveryListenerTestCase.java

public static File createTempDirectory() throws IOException {
    final File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
    if (!(temp.delete())) {
        throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());
    }//w  w w  . j ava2  s  . com

    if (!(temp.mkdir())) {
        throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());
    }

    return temp;
}

From source file:com.genericworkflownodes.knime.custom.ZipUtilsTest.java

public static File createTempDirectory() throws IOException {
    final File temp;

    temp = File.createTempFile("temp", Long.toString(System.nanoTime()));

    if (!(temp.delete())) {
        throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());
    }/*from  w  ww .ja  va 2 s.c o m*/

    if (!(temp.mkdir())) {
        throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());
    }

    return (temp);
}

From source file:com.github.aliakhtar.annoTest.util.Compiler.java

private static File createTempDir(String prefix) throws IOException {
    File file = File.createTempFile(prefix, null);
    if (!file.delete()) {
        throw new IOException("Unable to delete temporary file " + file.getAbsolutePath());
    }/*from  w w  w  .j a  v a2s .c  o  m*/
    if (!file.mkdir()) {
        throw new IOException("Unable to create temp directory " + file.getAbsolutePath());
    }
    return file;
}

From source file:com.jaeksoft.searchlib.Logging.java

private final static Properties getLoggerProperties(String instanceId) throws SearchLibException {
    File dirLog = getLogDirectory();
    if (!dirLog.exists())
        dirLog.mkdir();
    Properties props = new Properties();
    if (isDebug)/*from ww w.  j  a  v a 2  s  .  co m*/
        props.put("log4j.rootLogger", "DEBUG, R");
    else
        props.put("log4j.rootLogger", "INFO, R");
    props.put("log4j.appender.R", "org.apache.log4j.DailyRollingFileAppender");
    String logPath = StringUtils.fastConcat("logs", File.separator, "oss.", instanceId, ".log");
    File logFile = new File(StartStopListener.OPENSEARCHSERVER_DATA_FILE, logPath);
    props.put("log4j.appender.R.File", logFile.getAbsolutePath());
    props.put("log4j.appender.R.DatePattern", "'.'yyyy-MM-dd");
    props.put("log4j.appender.R.layout", "org.apache.log4j.PatternLayout");
    props.put("log4j.appender.R.layout.ConversionPattern", "%d{HH:mm:ss,SSS} %p: %c - %m%n");
    props.put("log4j.logger.org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper", "ERROR");
    return props;
}

From source file:com.amazonaws.codepipeline.jenkinsplugin.ExtractionTools.java

private static void extractArchive(final File destination, final ArchiveInputStream archiveInputStream)
        throws IOException {
    final int BUFFER_SIZE = 8192;
    ArchiveEntry entry = archiveInputStream.getNextEntry();

    while (entry != null) {
        final File destinationFile = getDestinationFile(destination, entry.getName());

        if (entry.isDirectory()) {
            destinationFile.mkdir();
        } else {/*from  w ww  . j a v a  2  s .  c  o  m*/
            destinationFile.getParentFile().mkdirs();
            try (final OutputStream fileOutputStream = new FileOutputStream(destinationFile)) {
                final byte[] buffer = new byte[BUFFER_SIZE];
                int bytesRead;

                while ((bytesRead = archiveInputStream.read(buffer)) != -1) {
                    fileOutputStream.write(buffer, 0, bytesRead);
                }
            }
        }

        entry = archiveInputStream.getNextEntry();
    }
}

From source file:com.beginner.core.utils.FileZip.java

/**
 * ?ZIP-?,?,??/*from   w  w  w.  ja v a2s . c om*/
 * @param zipFile       ZIP
 * @param dest          
 * @param passwd       ZIP?
 * @return             ?
 * @throws ZipException ???
 */
public static File[] unzip(File zipFile, String dest, String passwd) throws ZipException {
    ZipFile zFile = new ZipFile(zipFile);
    zFile.setFileNameCharset("GBK");
    if (!zFile.isValidZipFile()) {
        throw new ZipException("??,????.");
    }
    File destDir = new File(dest);
    if (destDir.isDirectory() && !destDir.exists()) {
        destDir.mkdir();
    }
    if (zFile.isEncrypted()) {
        zFile.setPassword(passwd.toCharArray());
    }
    zFile.extractAll(dest);

    @SuppressWarnings("unchecked")
    List<FileHeader> headerList = zFile.getFileHeaders();
    List<File> extractedFileList = new ArrayList<File>();
    for (FileHeader fileHeader : headerList) {
        if (!fileHeader.isDirectory()) {
            extractedFileList.add(new File(destDir, fileHeader.getFileName()));
        }
    }
    File[] extractedFiles = new File[extractedFileList.size()];
    extractedFileList.toArray(extractedFiles);
    return extractedFiles;
}

From source file:com.application.error.ExceptionHandler.java

/**
 * Search for stack trace files.//from  w ww .  j  av  a2 s  .co  m
 * @return
 */
private static String[] searchForStackTraces() {
    if (stackTraceFileList != null) {
        return stackTraceFileList;
    }
    File dir = new File(G.FILES_PATH + "/");
    // Try to create the files folder if it doesn't exist
    dir.mkdir();
    // Filter for ".stacktrace" files
    FilenameFilter filter = new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return name.endsWith(".stacktrace");
        }
    };
    return (stackTraceFileList = dir.list(filter));
}

From source file:ezbake.deployer.impl.Files.java

public static File createTempDirectory(File baseDir, String prefix) {
    String baseName = prefix + "-" + System.currentTimeMillis() + "-";

    for (int counter = 0; counter < TEMP_DIR_ATTEMPTS; counter++) {
        File tempDir = new File(baseDir, baseName + counter);
        if (tempDir.mkdir()) {
            return tempDir;
        }/*from   w  w w .  j  av a 2 s.c o m*/
    }
    throw new IllegalStateException("Failed to create directory within " + TEMP_DIR_ATTEMPTS
            + " attempts (tried " + baseName + "0 to " + baseName + (TEMP_DIR_ATTEMPTS - 1) + ')');
}

From source file:com.photon.phresco.util.FileUtil.java

public static void copyFolder(File src, File dest) throws IOException {
    if (src.isDirectory()) {
        //if directory not exists, create it
        if (!dest.exists()) {
            dest.mkdir();
        }/*from  w w  w  . j  a va2s  .com*/

        //list all the directory contents
        String files[] = src.list();

        for (String file : files) {
            //construct the src and dest file structure
            File srcFile = new File(src, file);
            File destFile = new File(dest, file);
            //recursive copy

            if (!Constants.MACOSX.equals(file)) {
                copyFolder(srcFile, destFile);
            }
        }
    } else {
        //if file, then copy it
        //Use bytes stream to support all file types
        InputStream in = new FileInputStream(src);
        OutputStream out = new FileOutputStream(dest);

        byte[] buffer = new byte[BUFFER_SIZE];

        int length;
        //copy the file content in bytes 
        while ((length = in.read(buffer)) > 0) {
            out.write(buffer, 0, length);
        }
        in.close();
        out.close();
    }
}

From source file:it.geosolutions.sfs.web.Start.java

private static SslSocketConnector getSslSocketConnector(String hostname) {

    String password = "changeit";
    SslSocketConnector conn = new SslSocketConnector();
    conn.setPort(8443);/*from w w w.j a va2s .  c  o  m*/
    File userHome = new File(System.getProperty("user.home"));
    File geoserverDir = new File(userHome, ".geoserver");
    if (geoserverDir.exists() == false)
        geoserverDir.mkdir();
    File keyStoreFile = new File(geoserverDir, "keystore.jks");
    try {
        assureSelfSignedServerCertificate(hostname, keyStoreFile, password);
    } catch (Exception e) {
        //                log.log(Level.WARNING, "NO SSL available", e);
        return null;
    }
    conn.setKeystore(keyStoreFile.getAbsolutePath());
    conn.setKeyPassword(password);
    conn.setPassword(password);
    File javaHome = new File(System.getProperty("java.home"));
    File cacerts = new File(javaHome, "lib");
    cacerts = new File(cacerts, "security");
    cacerts = new File(cacerts, "cacerts");

    if (cacerts.exists() == false)
        return null;
    conn.setTruststore(cacerts.getAbsolutePath());
    conn.setTrustPassword("changeit");
    return conn;
}