递归创建多级目录

  public static void mkDir(File file) {

        if (file.getParentFile().exists()) {

            file.mkdir();

        } else {

            mkDir(file.getParentFile());

            file.mkdir();

        }

    }

    // 最后是程序的调用方法

    public static void main(String[] args)

        throws IOException {

        File file = new File("e:/2/1/s/e");

        mkDir(file);

    }

猜你喜欢

转载自blog.csdn.net/chinaxiaofeng8/article/details/82458862
今日推荐