0

How do I make a directory outside the war file of my web-app ? Till now I have been making the directory like :

(request.getServletContext().getRealPath("/")).mkdir()

But I want to create the directory outside the build folder of my project ? How do I do this ?

(This is in-case a server doesn't unpack the war)

saplingPro
  • 19,801
  • 53
  • 136
  • 190

1 Answers1

1

The simplest way I can think of is to create a class like:

class FolderMaker{
      private String base="/home/user/base/"; // should be configurable, but this is sample

      public boolean mkdir(name){
          return new File(base, name).mkdir();
      }
}

This class works like a simple Java SE class that creates a directory somewhere at disk.

BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
Koziołek
  • 2,681
  • 1
  • 26
  • 44