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:edu.clemson.cs.nestbed.server.util.FileUtils.java

public static File makeProgramDir(File root, int testbedID, int projectID, int programID) {
    File dir = new File(root, Integer.toString(testbedID));
    dir.mkdir();

    dir = new File(dir, Integer.toString(projectID));
    dir.mkdir();//  w ww .j av  a  2  s . c  om

    dir = new File(dir, Integer.toString(programID));
    dir.mkdir();

    return dir;
}

From source file:com.na.install.JerseyWizardTest.java

@BeforeClass
public static void beforeClass() throws IOException {
    File f = new File("WEB-INF");
    if (!f.exists()) {
        f.mkdir();
        f = new File("WEB-INF/classes");
        f.mkdir();//from  w w w  .j  a v  a2  s .c  o m
        return;
    }

    f = new File("WEB-INF/classes/META-INF");
    if (f.exists()) {
        FileUtils.deleteDirectory(f);
    }
}

From source file:Main.java

public static File getDiskCacheDir(Context context, String uniqueName) {
    String cachePath;/*from ww w.jav  a 2  s . c om*/
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            || !Environment.isExternalStorageRemovable()) {
        File externalCacheDir = context.getExternalCacheDir();
        // context.getExternalCacheDir() maybe null
        if (externalCacheDir == null) {
            cachePath = context.getCacheDir().getPath();
        } else {
            cachePath = externalCacheDir.getPath();
        }
    } else {
        cachePath = context.getCacheDir().getPath();
    }
    File file = new File(cachePath + File.separator + uniqueName);
    if (!file.exists() && !file.isDirectory()) {
        file.mkdir();
    }
    return file;
}

From source file:in.co.sneh.model.CargaExcelRuralModel.java

public static boolean processFile(String path, FileItemStream item) {
    try {//w w w  .j av a 2  s. com
        File f = new File(path + File.separator + "exceles" + File.separator);
        if (!f.exists()) {
            f.mkdir();
        }
        File savedFile = new File(f.getAbsolutePath() + File.separator + item.getName());
        FileOutputStream fos = new FileOutputStream(savedFile);
        InputStream is = item.openStream();
        int x = 0;
        byte[] b = new byte[1024];
        while ((x = is.read(b)) != -1) {
            fos.write(b, 0, x);
        }
        fos.flush();
        fos.close();
        return true;
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
    return false;
}

From source file:net.sf.dsig.helpers.UserHomeSettingsParser.java

public static Properties parse() {
    try {/*from   w  ww . ja va  2 s .c om*/
        String userHome = System.getProperty("user.home");
        File dsigFolder = new File(userHome, ".dsig");
        if (!dsigFolder.exists() && !dsigFolder.mkdir()) {
            throw new IOException("Could not create .dsig folder in user home directory");
        }

        File settingsFile = new File(dsigFolder, "settings.properties");
        if (!settingsFile.exists()) {
            InputStream is = UserHomeSettingsParser.class.getResourceAsStream("/defaultSettings.properties");
            if (is != null) {
                IOUtils.copy(is, new FileOutputStream(settingsFile));
            }
        }

        if (settingsFile.exists()) {
            Properties p = new Properties();
            FileInputStream fis = new FileInputStream(settingsFile);
            p.load(fis);
            IOUtils.closeQuietly(fis);
            return p;
        }
    } catch (IOException e) {
        logger.warn("Error while initialize settings", e);
    }

    return null;
}

From source file:Main.java

/**
 * Returns a Java File initialized to a directory of given name
 * within the given location./*from  w ww  . j a v a  2s.  co  m*/
 *
 * @param parent_directory a File representing the directory in which the new child will reside
 * @return a File pointing to the desired directory, or null if a file with conflicting name
 * exists or if getRootStorageDirectory was not called first
 */
public static File getStorageDirectory(File parent_directory, String new_child_directory_name) {

    File result = new File(parent_directory, new_child_directory_name);
    if (!result.exists())
        if (result.mkdir())
            return result;
        else {
            Log.e("getStorageDirectory", "Error creating " + result.getAbsolutePath());
            return null;
        }
    else if (result.isFile()) {
        return null;
    }

    Log.d("getStorageDirectory", "directory ready: " + result.getAbsolutePath());
    return result;
}

From source file:Main.java

public static void createDir(String dirPath) {
    File dir = new File(dirPath);
    if (!dir.exists()) {
        Log.d("createDir", dir.getPath() + " does not exist. Creating");
        if (!dir.mkdir()) {
            Log.e("createDir", "Unable to create " + dir.getPath());
        }// w  w w. j a  v a2  s.  com
    }

}

From source file:Main.java

public static File getAlbumFolder(String albumName) {
    File folder = new File(Environment.getExternalStorageDirectory() + File.separator + albumName);
    if (!folder.exists()) {
        folder.mkdir();
        try {/* w  w w  .j  av  a2s .co  m*/
            new File(folder, ".yesmedia").createNewFile();
        } catch (Exception e) {
            Log.d(TAG, "[AirImagePickerUtils] exception = " + e.getMessage());
            Log.d(TAG, "[AirImagePickerUtils] Exiting didSavePictureInGallery (failed)");
            return null;
        }
    }
    return folder;
}

From source file:gov.nih.nci.cabig.caaers.testdata.TestDataFileUtils.java

public static File createFolder(File f) {
    if (!f.exists())
        f.mkdir();
    if (!f.isDirectory())
        throw new RuntimeException("The folder " + f.getPath() + ", unable to create");
    return f;/*from w ww  .ja  v  a 2  s. c o  m*/
}

From source file:Main.java

public static void makeDirectory(String filePath) {
    File file = null;
    try {//from  www.  j  a v a  2s  .com
        file = new File(filePath);
        if (!file.exists()) {
            file.mkdir();
        }
    } catch (Exception e) {

    }
}