Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create all directories up to a point?

Tags:

java

file-io

I need to be able to build all directories up to and including the directory specified by my File object. For example, suppose I have something like this:

File file = new File( "/var/a/b/c/d/" );

But only /var/ exists. I need a method that builds up to d, and I was wondering if there was a method in a java io library somewhere that does this already.

like image 734
Stefan Kendall Avatar asked Dec 02 '22 05:12

Stefan Kendall


1 Answers

mkdirs() in java.io.File does the trick.

File file = new File("/var/a/b/c/d");

file.mkdirs();
like image 154
Joey Gibson Avatar answered Dec 22 '22 21:12

Joey Gibson