Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

making a file directory in java  RSS feed

 
kay lin
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all:
I would like to make a file direcotory in Java, so I did was the following


C:\\jbproject\\AJJavaModelApplicationOCT7.bkp\\JavaModelApplicationAAAEJB\\META-INF\\ is the name of the directory I want,

but when i run the program, it is not making the file directory..can somebody let me know what I am doing wrong??

Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks OK, assuming that all the directories but the META-INF one already exist. Are you sure you typed that nasty pathname correctly?

You might try printing the value of

new File("C:\\jbproject\\AJJavaModelApplicationOCT7.bkp\\JavaModelApplicationAAAEJB\\").exists();

it should print "true".

If not all the directories already exist, you need to create them one at a time from the top down.
 
kay lin
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
That looks OK, assuming that all the directories but the META-INF one already exist. Are you sure you typed that nasty pathname correctly?

You might try printing the value of

new File("C:\\jbproject\\AJJavaModelApplicationOCT7.bkp\\JavaModelApplicationAAAEJB\\").exists();

it should print "true".

If not all the directories already exist, you need to create them one at a time from the top down.


I see..I think i might know what my problem is...
the \\JavaModelApplicationAAAEJB\\ doesnt exit
so I guess I will have to create that directory first..and then the \\META-INF\\ correct? plz let me know

many thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's right.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remember correctly, there is also a mkdirs() method that will create all the directories in the path.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!