Java Create Directory mkDirAndFile(File file)

Here you can find the source of mkDirAndFile(File file)

Description

mk Dir And File

License

Apache License

Declaration

public static void mkDirAndFile(File file) throws IOException 

Method Source Code


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

import java.io.File;

import java.io.IOException;

public class Main {
    public static void mkDirAndFile(File file) throws IOException {
        if (file.exists()) {
            return;
        }/*from   www. j a v a  2  s.  c o m*/
        if (!file.getParentFile().exists()) {
            mkDir(file.getParentFile());
        }
        file.createNewFile();
    }

    public static void mkDir(File dir) {
        if (dir.exists()) {
            return;
        }
        if (dir.getParentFile().exists()) {
            dir.mkdir();
        } else {
            mkDir(dir.getParentFile());
            dir.mkdir();
        }
    }
}

Related

  1. mkdir(String path)
  2. mkDir(String path)
  3. mkdir(String s)
  4. mkdir(String save)
  5. mkdir(String sFullDirName)
  6. mkdirIfMissing(File dir)
  7. mkdirIfNotExists(File dir)
  8. mkDirRec(File file)
  9. mkdirs(File folder)