亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android清除工程中無用資源文件的兩種方法

 更新時間:2016年08月02日 17:20:47   作者:u011771755  
這篇文章主要介紹了Android清除工程中無用資源文件的兩種方法,調(diào)用Android lint命令查找出無用資源,二是使用代碼自動刪除無用的文件,感興趣的小伙伴們可以參考一下

一、調(diào)用Android lint命令查找出沒有用到的資源,并生成一個清單列表:


命令:lint –check “UnusedResources” [project_path] > result.txt
執(zhí)行完之后會生成一個清單文件,內(nèi)容如下:

二、使用代碼自動刪除無用的文件:

public class DelAction
{
  public static void main(String[] args)
    throws IOException
  {
    String projectPath = "***";
    BufferedReader reader = new BufferedReader(new FileReader("result路徑"));
    String line;
    int count = 0;
    while ((line = reader.readLine()) != null)
    {
      if (line.contains("UnusedResources") && !line.contains("res/value") && !line.contains("appcompat"))
      {
        count++;
        int end = line.indexOf(":");
        if (end != -1)
        {
          String file = line.substring(0, end);
          String f = projectPath + file;
          boolean flag =
            new File("【拼出文件完整路徑】" + f.replace("***", "")).delete();          System.out.println("【拼出文件完整路徑】" + f + "=>del=>" + flag);
        }
      }
    }
  }
}

我們往往要多次重復(fù)執(zhí)行上面的操作,才能真正徹底的清除工程中無用的資源文件。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論