Solved

Creating directory using java ?

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to add new optional parameter to JSP 1 49
Java program running SQL query 5 37
web project error add remove 1 27
jsp error 6 25
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

792 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