The following is a servlet that attempts to create a directory and a text file inside that directory.
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
String s = request.getServletContext().getRealPath("/");
PrintWriter out = response.getWriter();
FileMaker fm = new FileMaker();
fm.makeDirectoryTester();
}
Class that makes a directory and a text file in it :
public void makeDirectoryTester() {
try {
File f = new File("FlushTester/");
if(!f.exists()) {
boolean b = f.mkdir();
System.out.println("Directory Made (Inside makeDirectoryTester) --> " + b);
PrintWriter writer = new PrintWriter("FlushTester/TESTER.txt");
writer.println("This is the first statement");
writer.println("This is the second statement");
writer.println("This is the third statement");
writer.close();
}
}catch(Exception exc) {
exc.printStackTrace();
}
}
The problem is that the boolean f.mkdir() returns true
but I cannot see any directory created or any file inside it ! Why is that ? I am using tomcat as the server. What could be the reason for this ?