Solved

Creating directory using java ?

Posted on 2004-03-30
7
364 Views
Last Modified: 2010-03-31

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

Thanks

Ramesh
0
Comment
Question by:Ramesh4u
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 25 total points
ID: 10720818
new File(dirname).mkdir();
0
 
LVL 9

Assisted Solution

by:mmuruganandam
mmuruganandam earned 25 total points
ID: 10720912
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
 
LVL 4

Expert Comment

by:illusionz70
ID: 10721296
try this..

String dirname = "your directory name"
File dir = new File(dirname);
  if(!dir.exists() )
         {
      dir.mkdirs();
            }
      
0
 

Author Comment

by:Ramesh4u
ID: 10721306
would mkdir works for all the operating system?
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10721312
Yes... It will work for every operating system
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 196
maven project error 5 56
java.io.BufferedReader   readLine()  //returns the entire file ? 4 73
more than one jdk and one jre 1 41
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question