Under SSH Framework code:
Public String Delerubbishad () {
int deleadcount = 0;
RUBBISHADTP = CONFIGDAO.RUBBISHADTP ();Collection of ad images in the database
map<object,object> shujuku= new hashmap<object,object> ();
File Adfile = new file ("C://program Files//apache software foundation//tomcat 6.0//webapps//plpwmanagers// Yesilovepjustdoit2014//adimg ");
String adarray[];
Adarray=adfile.list ();An array of ad images on the server, as the IE storage mechanism, the resulting files from the server contain a thumbs.db thumbnail file, where there is no need to process
Put a database ad image in map
for (Object SHUJUKUAD:RUBBISHADTP) {
Shujuku.put (Shujukuad, Shujukuad);
}
list<object> diffenttp= new arraylist<object> ();A picture used to store differences
Cycle through the images in the server which are not in the database
for (String Fuwuqi:adarray) {
if (Shujuku.containskey (Fuwuqi) ==false) {
Diffenttp.add (Fuwuqi);
}
}
To cycle through the deletion of the difference picture
for (int i =0;i<diffenttp.size () -1;i++) {//thumbs.db file does not need to be processed
Find the diff picture on the server
File filead= new file (Servletactioncontext.getservletcontext (). Getrealpath ("yesilovepjustdoit2014/adimg") + "/" + Diffenttp.get (i));
Filead.delete ();
deleadcount++; Record how many diff images were deleted
}
Rubbadmap.put ("Lajiadcount", Diffenttp.size ()-1);
Rubbadmap.put ("Deleadcounts", Deleadcount);
return "DELERUBBISHADSUC"; Returns the number of trash pictures, deleting the number of pictures
}