我在 JSP 中創建了一個檔案,它在 Apache Bin 檔案夾位置創建:apache-tomcat-9.0.65\bin。我想在專案目錄中創建它。如何創建它。
File myObj = new File("test.txt");
myObj.createNewFile();
uj5u.com熱心網友回復:
你可以試試這個:
File myDirectory = "/apache-tomcat-9.0.65/bin/";
File myObj = new File(myDirectory, "test.txt");
myObj.createNewFile();
如果您使用的是 Windows,則可能必須對目錄使用反斜杠(并正確轉義它們):
File myDirectory = "C:\\apache-tomcat-9.0.65\\bin\\";
我希望它有幫助
uj5u.com熱心網友回復:
正文代碼檔案jsp
<%@page import="java.io.File"%>
<%
File myObj = new File("test.txt");
myObj.createNewFile();
%>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/516554.html
標籤:爪哇jsp
