1. 程式人生 > >Checking if a file exists.

Checking if a file exists.

這個 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/>");