Question

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?

Was it helpful?

Solution

new File("${request.getContextPath()}/example.txt")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top