title: return existing file using Java Jersey
body: <p>I am currently returning a file from Java jersey using an absolute path to a local folder as shown below</p>
  
  <pre><code>@Path("/database")
  @Stateful
  public class DBResource
  {
          @GET
          @Path("/get/7zip")
          @Produces("application/7z")
          public StreamingOutput getDatabase()
          {
              java.io.File file = new java.io.File("/home/jack.jude/myfile.7z");
              return new FileStreamingOutput(file);
          }
  }
  </code></pre>
  
  <p>I wonder how can I return a resource from within the application taking into account that</p>
  
  <pre><code>Thread.currentThread().getContextClassLoader().getResource("");
  </code></pre>
  
  <p>doesn't return a meaningful path and</p>
  
  <pre><code>   String rootPath = getServletConfig().getServletContext().getRealPath("/");
  </code></pre>
  
  <p>cannot be used because I'm not inside a servlet but inside a Resource.</p>