漂泊在外的孤独患者 2015-09-09 08:17 采纳率: 28.6%
浏览 7132

关于new File(path) 路径找不到的问题,我想删除服务器上的图片。

代码是这样的:
//删除图片
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\……
求大神!!!

  • 写回答

2条回答 默认 最新

  • threenewbee 2015-09-09 08:34
    关注

    path不能是url地址,必须是你的服务器上的路径,驱动器名开头,比如 C:\\folder\\...

    评论

报告相同问题?