0
如下圖所示使用Java澤西返回現有文件
@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);
}
}
我不知道我目前恢復使用到本地文件夾的絕對路徑從Java球衣文件我怎樣才能從內部應用考慮到返回的資源帳戶
Thread.currentThread().getContextClassLoader().getResource("");
不會返回一個有意義的路徑和
String rootPath = getServletConfig().getServletContext().getRealPath("/");
CA不能使用,因爲我不在一個servlet中,而是在一個資源中。