Java mkdir makeDirs(String filePath)

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

Description

make Dirs

License

Apache License

Declaration

public static boolean makeDirs(String filePath) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    public static boolean makeDirs(String filePath) {
        String folderName = getFolderName(filePath);
        if (folderName == null || folderName.trim().length() == 0) {
            return false;
        }/*from w  ww.j a va 2s.c o  m*/

        File folder = new File(folderName);
        return (folder.exists() && folder.isDirectory()) ? true : folder.mkdirs();
    }

    public static String getFolderName(String filePath) {

        if (filePath == null || filePath.trim().length() == 0) {
            return filePath;
        }

        int filePosi = filePath.lastIndexOf(File.separator);
        return (filePosi == -1) ? "" : filePath.substring(0, filePosi);
    }
}

Related

  1. makeDirs(final File file)
  2. makeDirs(String dir)
  3. makeDirs(String fileName)
  4. makedirs(String fileName)
  5. makeDirs(String fileName, boolean hasFile)
  6. makeDirs(String strBottomFoldName, String strFoldName)
  7. makeDIRS(String[] dirs, File path)
  8. makeDirsFor(File file)
  9. makeDirsWhenNotExist(String filePath)