public static void createNewDirIfNotExist(File dir) {

        if (dir == null) {
            throw new NullPointerException();
        }

        checkIsDir(dir);

        if (!dir.exists()) {
            // Fix the p. So the file can get its parent file.
            dir = new File(dir.getAbsolutePath());

            File parentDir = dir.getParentFile();

            createNewDirIfNotExist(parentDir);

            if (!dir.mkdir()) {
                throw new RuntimeException("bad luck.");
            }
        }
    }