To create a folder in Java, call the
File.mkdirs
method.For example, this is how you can create a new folder/directory called Important Documents
inside /Users/whaadev
directory:
new File("/Users/whaadev/Important Documents").mkdirs();
This will also create all nonexistent parent directories.