Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes create a folder from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "create a folder from a servlet" Watch "create a folder from a servlet" New topic
Author

create a folder from a servlet

Ishita Saha
Ranch Hand

Joined: May 30, 2007
Posts: 39
Hi,

I need to check whether a particular folder exists from my servlet code and if doesn't then i need to create one.

Can i do that in Java servlet?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42371
    
  64
Yes. Are you familiar with the java.io.File class? It contains mkdir and mkdirs methods.

Note that file I/O may be forbidden by a security manager if the directories are not inside of the web applications root directory. But you'll see soon enough if that's the case; no harm in trying first.


Ping & DNS - my free Android networking tools app
Ishita Saha
Ranch Hand

Joined: May 30, 2007
Posts: 39
Thanks Ulf,
It did work very well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: create a folder from a servlet