Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

create a directory

Posted on 2004-08-23
5
Medium Priority
?
304 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
ID: 11869980
boolean success = (new File(createDirName)).mkdir();
0
 
LVL 8

Author Comment

by:thomas908
ID: 11870004
already tried doesn't help
0
 
LVL 35

Accepted Solution

by:
TimYates earned 400 total points
ID: 11870029
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
ID: 11870056
oops!
My mistake. was doing it wrong.
thanks for helping
0
 
LVL 35

Expert Comment

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

Good luck with it :-)

Tim
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

926 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