public static void main(String[] args) {
String dir = System.getProperty("user.dir");
dir = dir + File.separator + "arptmp";
File f = new File(dir);
if(!f.exists()) {
f.mkdirs();
}
dir = f.getPath() + File.separator + "servlet_.dot";
f = new File(dir);
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
new file的时候写绝对路径。不要写相对路径,
String rootPath=request.getRealPath("/");//获取项目根目录
String path=rootPath+"arptmp\\";//这就是你想要的目录