Solved

create a directory

Posted on 2004-08-23
5
276 Views
Last Modified: 2010-03-31
I have to create a directory with a specified name.
I am using the following

          boolean success = (new File(createDirName)).mkdirs();
          if (!success) {
           System.out.println("Directory creation failed");
          }


this code fails.
createDirName is a String variable which contains the value E:\del\06-08-2004
E:\del already exists. it just needs to create a directory with the name 06-08-2004. this value can't be harcoded as it is fetched at runtime.
0
Comment
Question by:thomas908
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
boolean success = (new File(createDirName)).mkdir();
0
 
LVL 8

Author Comment

by:thomas908
Comment Utility
already tried doesn't help
0
 
LVL 35

Accepted Solution

by:
TimYates earned 100 total points
Comment Utility
should work (so should yours) assuming you have write permission for the "del" directory...

Ahh...is "E:" not the drive you are running the java app from?

According to this:

http://java.ittoolbox.com/documents/document.asp?i=2633

You need to do something with FileSystemView inside javax.swing.filechooser.* ;
0
 
LVL 8

Author Comment

by:thomas908
Comment Utility
oops!
My mistake. was doing it wrong.
thanks for helping
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
Glad you got it sorted and thanks for the points!! :-)

Good luck with it :-)

Tim
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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

8 Experts available now in Live!

Get 1:1 Help Now