Hen I create a file in JSP the its created in Apache Bin folder location: apache-tomcat-9.0.65\bin. I want to create it in project directory. How to create it.
File myObj = new File("test.txt");
myObj.createNewFile();
CodePudding user response:
Body code file jsp
<%@page import="java.io.File"%>
<%
File myObj = new File("test.txt");
myObj.createNewFile();
%>
CodePudding user response:
You could try this:
File myDirectory = "/apache-tomcat-9.0.65/bin/";
File myObj = new File(myDirectory, "test.txt");
myObj.createNewFile();
if you're using windows you may have to use backslashes instead for the directory (and escape them properly):
File myDirectory = "C:\\apache-tomcat-9.0.65\\bin\\";
I hope it helps