• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

create a directory

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
thomas908
Asked:
thomas908
  • 3
  • 2
1 Solution
 
TimYatesCommented:
boolean success = (new File(createDirName)).mkdir();
0
 
thomas908Author Commented:
already tried doesn't help
0
 
TimYatesCommented:
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
 
thomas908Author Commented:
oops!
My mistake. was doing it wrong.
thanks for helping
0
 
TimYatesCommented:
Glad you got it sorted and thanks for the points!! :-)

Good luck with it :-)

Tim
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now