Java mkdir makeDirsWhenNotExist(String filePath)

Here you can find the source of makeDirsWhenNotExist(String filePath)

Description

make Dirs When Not Exist

License

Open Source License

Declaration

private static boolean makeDirsWhenNotExist(String filePath) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    private static boolean makeDirsWhenNotExist(String filePath) {
        String separator = null;/*from   w ww .j a  va  2  s. com*/
        if (filePath.indexOf("/") > -1) {
            separator = "/";
        } else if (filePath.indexOf("\\") > -1) {
            separator = "\\";
        }
        int index = filePath.lastIndexOf(separator);
        String cataloguePath = filePath.substring(0, index);
        File file = new File(cataloguePath);
        if (!file.exists()) {
            file.mkdirs();
        }
        return true;
    }
}

Related

  1. makeDirs(String fileName, boolean hasFile)
  2. makeDirs(String filePath)
  3. makeDirs(String strBottomFoldName, String strFoldName)
  4. makeDIRS(String[] dirs, File path)
  5. makeDirsFor(File file)