Solved

Creating directory using java ?

Posted on 2004-03-30
7
344 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now