首页 > 代码库 > [Android]_[初级]_[sdk docs reference api 文档打开慢的解决办法]
[Android]_[初级]_[sdk docs reference api 文档打开慢的解决办法]
场景:
1. 下载sdk时下载了docs/reference文档,文档是html形式的,因为里面带有google的相关网址,浏览器打开时会去访问这些被墙的网址,所以显示巨慢。
2. 解决办法就是遍历子目录删除google相关网址,由于是android开发,就用Java实现吧.
3.以下运行用时9分钟,i5双核,4G内存,开了其他东西,最新的sdk docs,android 5L.
文件.Cleaner.java
import java.io.*; public class Cleaner { public static void main(String[] args) { System.out.println("begin to clean google.com;googleapis.com;google-analytics.com"); String currentDir = args[0]; Cleaner c = new Cleaner(); c.work(currentDir); System.out.println("end to clean google.com;googleapis.com;google-analytics.com"); } public Cleaner(){} public void work(String currentDir){ File file = new File(currentDir); deleteReference(file); } public void deleteReference(File file) { String[] files = file.list(); String path = file.getPath(); for (String one : files) { String filePath = path+File.separatorChar+one; // System.out.println(filePath); File fileTemp = new File(filePath); if(fileTemp.isDirectory()) { deleteReference(fileTemp); }else{ // delete google reference if(filePath.endsWith(".html")) { try { BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileTemp),"UTF-8")); filePath = filePath+".tmp"; File newFile = new File(filePath); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile),"UTF-8")); String line = null; while((line = br.readLine())!= null) { String newLine = line.replaceAll("google\\.com|googleapis\\.com|google-analytics\\.com",""); bw.write(newLine); bw.newLine(); } br.close(); bw.close(); fileTemp.delete(); newFile.renameTo(fileTemp); }catch(Exception e) { e.printStackTrace(); } } } } } }
编译执行:
C:\Users\Admin\Desktop>javac Cleaner.java & java Cleaner E:\software\adt\sdk\docs\reference begin to clean google.com;googleapis.com;google-analytics.com end to clean google.com;googleapis.com;google-analytics.com
[Android]_[初级]_[sdk docs reference api 文档打开慢的解决办法]
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。