JSP – Checking if a file exists.

Posted in :

這個 sample code 滿簡單的:

ServletContext app = getServletContext();

String path = app.getRealPath("/");

File theFile = new File(path + "/images/your-file.jpg");

out.print("File Exists: " + theFile.exists() + "<br/>");

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *