栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 移动开发 > Android

android帮助文档打开慢的三种解决方法

Android 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

android帮助文档打开慢的三种解决方法

经查是因为本地文档中的网页有如下js代码会联网加载信息,将其注释掉后就好了

复制代码 代码如下:


用一下java代码就可以批量注释

复制代码 代码如下:
package cn.sd.fxd.android;


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;
   
    public static void main(String[] args) {

        File file = new File("D:/android/android-sdk-windows/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(".*?.html")) {
                String src = "";
                String dst = "";
                //如果是html文件则注释掉其中的特定javascript代码
                annotation(f, src, 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.replaceAll(src, dst);
        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;
        }
    }
}

网上有种方法是通过shell删除那行js代码,非常简洁方便,比我写的java方便100倍,I HATE JAVA

复制代码 代码如下:
find . -name "*.html"|xargs grep -l "jsapi"|xargs sed -i '/jsapi/d'

还有的方法是断网,或者用IE,firefox脱机浏览

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/165502.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号