Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File.createNewFile(); File.mkdir(); order  RSS feed

 
Brusk Baran
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I wonder why the following code does not work!

It just creates a file, but cannot convert the newly created file to a directory structure..
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something can either be a file or directory, not both at the same time. There is no way to convert a file to a directory, short of deleting the file and creating a directory with the same name. What exactly are you trying to accomplish?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're trying to create a new file, and (some of) the parent directory structure doesn't exist yet, you can try something like:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!