jQuery in Action, 3rd edition
The moose likes I/O and Streams and the fly likes File.createNewFile(); File.mkdir(); order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "File.createNewFile(); File.mkdir(); order" Watch "File.createNewFile(); File.mkdir(); order" New topic

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

Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
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

Joined: Oct 01, 2001
Posts: 2954

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

Joined: Jan 30, 2000
Posts: 18671
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:

"I'm not back." - Bill Harding, Twister
I agree. Here's the link: http://aspose.com/file-tools
subject: File.createNewFile(); File.mkdir(); order
It's not a secret anymore!