Android:快速比较脚本

时间:2013-06-24 17:56:10

标签: java android compare

我需要快速脚本(在Android中),它会返回电话簿中的丢失/过期文件。这是我的代码,但它很慢。这就像循环循环,这就是为什么它很慢。有更好的想法吗?

public List<String> _GetMissingFiles() 
{ 
    int checked_files = 0; 

    List<String> _Local_Files = getLocalFiles(new File(Config._SDCARD_DIR), null); 
    List<String> _FTP_Files = getFTPfiles(); 
    List<String> _Files_Need = new ArrayList<String>(); 

 try{ 
 for(int i  = 0; i < + _FTP_Files.size(); i++){ 

     boolean found = false; 
     double progress = (Double.valueOf(checked_files) / Double.valueOf(_FTP_Files.size())); 
     String[] _FTP_File_st = strTok(_FTP_Files.get(i), ";"); 
     String _FTP_File = _FTP_File_st[0]; 
     Date _FTP_File_date = new SimpleDateFormat("yyyy-MM-dd").parse(_FTP_File_st[1]); 

     FTP_SyncThread.doProgress("*"+_FTP_File); 
     FTP_SyncThread.doProgress("^"+(_FTP_Files.size() - checked_files)); 
     FTP_SyncThread.doProgress("["+progress); 
     Log.d("FTP","checked: "+checked_files+ " max: "+_FTP_Files.size()); 

     for(int x = 0; x < + _Local_Files.size(); x++){ 

         String[] _Local_File_st = strTok(_Local_Files.get(x), ";"); 
         String _Local_File = _Local_File_st[0]; 
         Date _Local_File_date = new SimpleDateFormat("yyyy-MM-dd").parse(_Local_File_st[1]); 

         if(_FTP_File.equals(_Local_File)) //Found file, now check date 
         { 
             if(_FTP_File_date.compareTo(_Local_File_date) <= 0) 
             { 
                 //DATE OK 
                 found = true; 
                 //Log.i("FTP","[OK]: File Found: "+_FTP_File); 
                 break; 
             } 
         }  
     } 

     checked_files += 1; 

     if(!found) 
     { 
         //Log.w("FTP","[ERR]: File Not Found or outdated: "+_FTP_File); 
         _Files_Need.add(_FTP_File); 
     } 
   } 
  } 
   catch (ParseException e) { 
      Log.e("FTP","Catch error: "+e.getMessage()); 
    } 

  return _Files_Need; 
}  

0 个答案:

没有答案