我想从我的过滤器上写到档案,然后能够在Eclipse读到,以确保我能正确写给它。
该法典编纂并实行罚款,但我不知道我可以读到哪里,或者我甚至写任何东西。
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
System.out.println("filter invoked");
InputStream in = null;
OutputStream out = null;
String inPath = context.getRealPath("/WEB-INF/template.txt");
String outPath = context.getRealPath("/WEB-INF/output.txt");
in = new FileInputStream(inPath);
out = new FileOutputStream(outPath);
OutputStreamWriter outstream = new OutputStreamWriter(out);
outstream.write("hello");
// pass the request along the filter chain
chain.doFilter(request, response);
}
文档模板.txt和输出.txt都在WEB-INF目录中。 我已经核实,从档案中读取的作品是有效的,但我可以核实这些文件的写本。 我每次都写出产出。 档案没有变化。
我对网上申请环境中的档案的书写有何了解?