//ファイル作成 File file = new File ("file path"); file.createNewFile();
//ファイル書き込み FileWriter fw = new FileWriter(file); fw.write ("write 1 \ r \ n"); fw.write ("write 2 \ r \ n");
//ファイル読み込み // (If I did this right after writing the above file, I got c == -1 in the first loop) int c; FileReader fw = new FIleReader(file); while( (c = fw.read()) != -1) { System.out.println( (char)c); }
//ファイルクローズ fw.close();
RequestDispatcher dis = request.getRequestDispatcher("dispatch.jsp"); dis.forward(request, response);
Recommended Posts