Home  >  Article  >  Java  >  Java Example - Recursively create directories

Java Example - Recursively create directories

黄舟
黄舟Original
2017-02-13 09:54:331362browse

以下实例演示了使用 File 类的 mkdirs() 实现递归创建目录 :

/*
 author by w3cschool.cc
 Main.java
 */import java.io.File;public class Main {
   public static void main(String[] args) {
      String directories = "D:\\a\\b\\c\\d\\e\\f\\g\\h\\i";
      File file = new File(directories);
      boolean result = file.mkdirs();
      System.out.println("Status = " + result);
   }}

以上代码运行输出结果为:

Status = true

以上就是Java 实例 - 递归创建目录的内容,更多相关内容请关注PHP中文网(www.php.cn)!



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn