How to create directories recursively?
SolutionFollowing example shows how to create directories recursively with the help of file.mkdirs() methods of File class.
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); } }Result
The above code sample will produce the following result.
Status = true
java_directories.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4