aspose file tools*
The moose likes Beginning Java and the fly likes create a file without directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "create a file without directory" Watch "create a file without directory" New topic
Author

create a file without directory

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I want to create a file in this path C:\\test\\A\\B\\myfile.txt. But the directory A, B and file 'myfile.txt' all are not existed.

Do I have easiest way to directly create that file, instead of creating directory A, B first ?

Thanks.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

http://download-llnw.oracle.com/javase/6/docs/api/java/io/File.html#mkdirs()

The documentation is your friend.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

But make sure you call that method on the parent file. If you call it on your current File object then you will create a folder with that name, and you can't create a file with the same name again until you remove the folder.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: create a file without directory
 
Similar Threads
problem with struts installation
writing a string to a file in diff directory
Cannot File The File Specified
How to create File object for servlet and so where to place the folder
Reading a file from a directory.