代码是这样的:
//删除图片
List t_path = Global.getTcmArtisanServiceLocator().getTcmArtisanService().getPicPath(Long.parseLong(artisanId));
String path = "";
if(!t_path.isEmpty()){
path = t_path.get(0).getPhotograph();
path = "http://126.532.156.59:8060/"+path;
}
File file = new File(path);
Boolean flag = file.exists();
if(flag){
file.delete();
}
现在的问题是new成file对象之后,斜杠变成\这样,http:\126.532.156.59:8060\……
求大神!!!
path不能是url地址,必须是你的服务器上的路径,驱动器名开头,比如 C:\\folder\\...
你不能在客户端上透过http协议去删除服务器上的文件。要用ftp协议或者文件共享协议。