@@ -18,7 +18,7 @@ public class FileThread implements Runnable {
1818 private AtomicInteger femaleIndex = new AtomicInteger (1 );
1919
2020 private HttpRequests httpRequests = new HttpRequests (
21- Main .API_KEY , Main .API_SECRET , true , true );
21+ Config .API_KEY , Config .API_SECRET , true , true );
2222
2323 private static String getGenderOrNull (JSONObject result ) {
2424 String gender ;
@@ -42,14 +42,15 @@ public void run() {
4242 if (cnt <= list .size () - 1 ) {
4343 file = list .get (cnt );cnt ++;
4444 }
45- } //unlock
45+ } //解锁
4646
4747 JSONObject result = null ;
4848 try {
4949 result = httpRequests .detectionDetect (new PostParameters ()
5050 .setImg (file ).setAttribute ("gender" ));
5151 } catch (FaceppParseException e ) {
52- e .printStackTrace ();
52+ System .out .println ("Error:\t " + file .getName () + " => " + e .getErrorMessage ());
53+ continue ;
5354 }
5455
5556 String gender = getGenderOrNull (result );
@@ -62,17 +63,21 @@ public void run() {
6263 index = maleIndex .getAndIncrement ();
6364 }
6465
65- //some file are ends with null : ZJ0P65PZN$CW6IU)2PJVMDQ.null
66+ //有些图片是.null后缀如 : ZJ0P65PZN$CW6IU)2PJVMDQ.null
6667 String destSuffix = FileUtils .getFileSuffix (file );
6768 if (destSuffix .equals ("null" )){
6869 destSuffix = "jpg" ;
6970 }
70- FileUtils .fileChannelCopy (file , new File (Main .destPath
71+ FileUtils .fileChannelCopy (file , new File (Config .destPath
7172 + "\\ " + gender + "\\ " + index + "." + destSuffix ));
72-
73+
7374 System .out .println (Thread .currentThread ().getName () + "\t "
7475 + file .getName () + " -> "
7576 + gender + "\\ " + index + "." + destSuffix );
77+
78+ if (Config .delSrcFile ){ //删源文件
79+ file .delete ();
80+ }
7681 }
7782
7883 }
0 commit comments