Creating directory using java ?


Could anyone tell me how to create a directory structure in my local drive ( I am using Unix stataion ) using java program.

Thanks

Ramesh
Ramesh4uAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
new File(dirname).mkdir();
0
 
mmuruganandamConnect With a Mentor Commented:
You can create a directory as suggested by Objects.

If you want to create one or more directories at one shot,

then

File file = new File(path);
file.mkdirs();


This way you can create all the directories at one shot.



Regards,
Muruga
0
 
illusionz70Commented:
try this..

String dirname = "your directory name"
File dir = new File(dirname);
  if(!dir.exists() )
         {
      dir.mkdirs();
            }
      
0
 
Ramesh4uAuthor Commented:
would mkdir works for all the operating system?
0
 
mmuruganandamCommented:
Yes... It will work for every operating system
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.