星空网 > 软件开发 > Java

Android 参考文档本地打开缓慢,JAVA解决方案

关于Android Develop 文档明明本地下载了,但在浏览器里打开还是很卡,原因是html文档中有链接Google服务器的Link和script。

网上有很多解决方案,其中一种是删除里面所有链接Google服务器的Link和script。

我在网上下载的JAVA代码这两行修饰css代码是怎么也删不掉,后来我读完代码发现有些bug.

<link rel="stylesheet"
href="http://fonts.googleapis.com/css?family=Roboto+Condensed">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold"
title="roboto">

以下是我参考别人的代码修改的JAVA代码解决方案,与别人JAVA代码的不同之处是能完全删除所有链接Google服务器的Link和script。

package deleteAndroidDoc;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;public class FormatDoc {  public static int j = 1;  /**   * @param args   */  public static void main(String[] args) {//    写你的文件所在的文件夹绝对路径    File file = new File("G:/Android Docs");    searchDirectory(file, 0);    System.out.println("OVER");  }  public static void searchDirectory(File f, int depth) {    if (!f.isDirectory()) {      String fileName = f.getName();      if (fileName.matches(".*.{1}html")) {        String src = "<link rel=\"stylesheet\"";        String src1 = "href=\"http://fonts.googleapis.com/css\\?family=Roboto\\+Condensed\">";        String src2 = "<script src='/images/loading.gif' data-original=\"http://www.google.com/jsapi\" type=\"text/javascript\"></script>";        String src3 = "<script src='/images/loading.gif' data-original=\"https://developer.android.com/ytblogger_lists_unified.js\" type=\"text/javascript\"></script>";        String src4 = "<link rel=\"stylesheet\" href=\"http://fonts.googleapis.com/css\\?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold\"";        String src5 = " title=\"roboto\">";        String dst = "";        // 匹配相应的并用""(空字符串)替代        annotation(f, src, dst);        annotation(f, src1, dst);        annotation(f, src2, dst);        annotation(f, src3, dst);        annotation(f, src4, dst);        annotation(f, src5, dst);      }    } else {      File[] fs = f.listFiles();      depth++;      for (int i = 0; i < fs.length; ++i) {        File file = fs[i];        searchDirectory(file, depth);      }    }  }  public static void annotation(File f, String src, String dst) {    String content = FormatDoc.read(f);    content = content.replaceFirst(src, dst);    int ll = content.lastIndexOf(src);    System.out.println(ll);    FormatDoc.write(content, f);    System.out.println(j++);    return;  }  public static String read(File src) {    StringBuffer res = new StringBuffer();    String line = null;    try {      BufferedReader reader = new BufferedReader(new FileReader(src));      int i = 0;      while ((line = reader.readLine()) != null) {        if (i != 0) {          res.append('\n');        }        res.append(line);        i++;      }      reader.close();    } catch (FileNotFoundException e) {      e.printStackTrace();    } catch (IOException e) {      e.printStackTrace();    }    return res.toString();  }  public static boolean write(String cont, File dist) {    try {      BufferedWriter writer = new BufferedWriter(new FileWriter(dist));      writer.write(cont);      writer.flush();      writer.close();      return true;    } catch (IOException e) {      e.printStackTrace();      return false;    }  }}

 




原标题:Android 参考文档本地打开缓慢,JAVA解决方案

关键词:JAVA

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

美国海外虚拟仓:https://www.goluckyvip.com/tag/38270.html
美国海外中转仓:https://www.goluckyvip.com/tag/38271.html
美国海运fba:https://www.goluckyvip.com/tag/38272.html
美国海运fba报价:https://www.goluckyvip.com/tag/38273.html
美国海运fba头程:https://www.goluckyvip.com/tag/38274.html
美国海运fba专线:https://www.goluckyvip.com/tag/38275.html
在古巴做游轮 古巴旅游项目:https://www.vstour.cn/a/363194.html
西藏旅游攻略自驾游需要多少天 去西藏旅游自驾游要多久时间:https://www.vstour.cn/a/363195.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流