我想打开一个文件并返回它的内容。虽然和要打开文件的类在同一个目录下,但是找不到文件。如果你能帮我解决问题会很酷。
这是代码:
@GET @Produces("text/html") @Path("/{partNO}/") @Consumes("text/html")
public String getPartNoResponseHTML(@PathParam("partNO") String parID) throws WebApplicationException {
PartNoTemplate partNo = getPartNoResponse(parID);
String result = "";
try {
result = readFile(PART_NO_TEMPLATE_FILE);
} catch (FileNotFoundException e) {
e.printStackTrace(System.out);
return e.getMessage() + e.toString();
// throw new WebApplicationException(Response.Status.NOT_FOUND);
} finally {
result = result.replace("{partNO}", parID);
result = result.replace("{inputFormat}", partNo.getFormat().toString());
}
return result;
}
我猜它找不到该文件,因为它在tomcat上运行。我也在使用 Jersey 和 JAX-RS。感谢您的帮助,
马克西