2

I want to use a File object to read a local file in the same directory as a groovlet. However, using a relative path to the file (either "example.txt" or "./example.txt") doesn't do the trick. If I give it an absolute path (e.g., "/example.txt"), then it works.

Is there any way to get the working directory or context path of the groovlet programmatically?

Steve Nay
  • 2,819
  • 1
  • 30
  • 41

1 Answers1

0
new File("${request.getContextPath()}/example.txt")
Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80
  • 1
    Great! But what I was actually going for is `getRealPath('/')`. Your answer pointed me in the right direction. Thanks! – Steve Nay Aug 24 '10 at 20:43