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
  • 20,769
  • 53
  • 137
  • 195

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,082,665
  • 372
  • 3,610
  • 3,555
Koziołek
  • 2,791
  • 1
  • 28
  • 48