Example usage for java.io File mkdirs

List of usage examples for java.io File mkdirs

Introduction

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

Prototype

public boolean mkdirs() 

Source Link

Document

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.

Usage

From source file:Main.java

private static void ensureDirectoryExists(String path) {
    File surveyDirectory = new File(path);
    if (!surveyDirectory.exists()) {
        surveyDirectory.mkdirs();
    }//from w ww. ja  v  a 2  s.c  om
}

From source file:Main.java

public static boolean existFile(String path, String fileName) {
    File filePath = new File(path);
    if (!filePath.isDirectory()) {
        filePath.mkdirs();
    }/*w  w  w.j a  v a 2s . c o m*/
    File file = new File(fileName);
    if (!file.exists() || !file.isFile()) {
        return false;
    }
    return true;
}

From source file:Main.java

public static boolean createFolder(String path) {
    boolean made = true;
    File dir = new File(path);
    if (!dir.exists()) {
        made = dir.mkdirs();
    }/*from  w  ww  . j  av  a  2s . c  o  m*/
    return made;
}

From source file:Main.java

/**
 * Saves a Bitmap object to disk for analysis.
 *
 * @param bitmap The bitmap to save.//from  w w  w  .  ja v a2  s  .  com
 */
public static void saveBitmap(final Bitmap bitmap) {
    final String root = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator
            + "tensorflow";
    //LOGGER.i("Saving %dx%d bitmap to %s.", bitmap.getWidth(), bitmap.getHeight(), root);
    final File myDir = new File(root);

    if (!myDir.mkdirs()) {
        //LOGGER.i("Make dir failed");
    }

    final String fname = "preview.png";
    final File file = new File(myDir, fname);
    if (file.exists()) {
        file.delete();
    }
    try {
        final FileOutputStream out = new FileOutputStream(file);
        bitmap.compress(Bitmap.CompressFormat.PNG, 99, out);
        out.flush();
        out.close();
    } catch (final Exception e) {
        //LOGGER.e(e, "Exception!");
    }
}

From source file:Main.java

public static void save(String paramString, Document paramDocument) throws Exception {
    DOMSource localDOMSource = new DOMSource(paramDocument);
    File localFile1 = new File(paramString);
    File localFile2 = localFile1.getParentFile();
    localFile2.mkdirs();
    StreamResult localStreamResult = new StreamResult(localFile1);
    try {// w w  w.ja v  a2  s. c om
        TransformerFactory localTransformerFactory = TransformerFactory.newInstance();
        Transformer localTransformer = localTransformerFactory.newTransformer();
        Properties localProperties = localTransformer.getOutputProperties();
        localProperties.setProperty("encoding", "UTF-8");
        localProperties.setProperty("indent", "yes");
        localTransformer.setOutputProperties(localProperties);
        localTransformer.transform(localDOMSource, localStreamResult);
    } catch (TransformerConfigurationException localTransformerConfigurationException) {
        localTransformerConfigurationException.printStackTrace();
    } catch (TransformerException localTransformerException) {
        localTransformerException.printStackTrace();
    }
}

From source file:Main.java

public static boolean CreateMkdir(String path) {
    try {//  ww  w  . ja  v a  2  s.c  om
        File file = new File(path);
        if (!file.exists()) {
            return file.mkdirs();
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static String getTablesFolder(String appName, String tableId) {
    String path;/*from ww w. j  a  v  a  2  s  .  c  om*/
    if (tableId == null || tableId.length() == 0) {
        throw new IllegalArgumentException("getTablesFolder: tableId is null or the empty string!");
    } else {
        if (!tableId.matches("^\\p{L}\\p{M}*(\\p{L}\\p{M}*|\\p{Nd}|_)+$")) {
            throw new IllegalArgumentException(
                    "getFormFolder: tableId does not begin with a letter and contain only letters, digits or underscores!");
        }
        path = getTablesFolder(appName) + File.separator + tableId;
    }
    File f = new File(path);
    f.mkdirs();
    return f.getAbsolutePath();
}

From source file:Main.java

public static void writeToFile(String fileName, String toWrite) throws IOException {
    File dir = new File(PHONE_BASE_PATH);
    if (!dir.exists()) {
        dir.mkdirs();
    }/* w  w w . j av a  2  s.c om*/
    File f = new File(PHONE_BASE_PATH, fileName);
    FileWriter fw = new FileWriter(f, true);
    fw.write(toWrite + '\n');
    fw.flush();
    fw.close();
    f = null;
}

From source file:Main.java

public static File getFileDirectorio(String pathDirectorio) {
    File filedir = new File(pathDirectorio);
    if (!filedir.exists())
        filedir.mkdirs();
    return filedir;
}

From source file:Main.java

public static String GetCacheFilePath() {
    String filePath = "";
    String rootpath = GetSdcardSystemPath();
    filePath = rootpath + CACHE_FILE;// www.java 2s . c om
    File file = new File(filePath);
    if (!file.exists()) {
        file.mkdirs();
    }
    return filePath;
}