int num=t.indexOf(".metadata");
String path=t.substring(1,num).replace('/', '\\')+"項目名\\WebContent\\文件";
//maven項目部署之後的文件路徑讀取
String FILE_SEPARATOR = System.getProperty("file.separator");String t=Thread.currentThread().getContextClassLoader().getResource("").getPath();
String projectName = request.getServletContext().getContextPath();
int num=t.indexOf(projectName);
String path=t.substring(0,num)+projectName+FILE_SEPARATOR+"export";
File f = new File(path.replace("/", FILE_SEPARATOR).replace("\\", FILE_SEPARATOR));
/maven項目本地環境的文件路徑讀取
String t=Thread.currentThread().getContextClassLoader().getResource("").getPath();
String projectName = request.getServletContext().getContextPath();
int num=t.indexOf(projectName);
String path=t.substring(1,num).replace('/', '\\')+projectName+"\\src\\main\\webapp\\export";
String path=t.substring(0,num)+projectName+FILE_SEPARATOR+"export";
File f = new File(path.replace("/", FILE_SEPARATOR).replace("\\", FILE_SEPARATOR));