Android help document to open slow three ways to solve _android

Source: Internet
Author: User
Tags stringbuffer

The search is because the Web page in the local document has the following JS code will be networked loading information, it will be commented out after the good

Copy Code code as follows:

<script src= "Http://www.google.com/jsapi" type= "Text/javascript" ></script>

Use Java code to batch comment

Copy Code code as follows:

Package cn.sd.fxd.android;

/*
* Remove JavaScript code that needs to be networked in the Android document
*/
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 ("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 = "<script src=\" http://www.google.com/jsapi\ "type=\" text/javascript\ "></script>";
String DST = "<!--<script src=\" http://www.google.com/jsapi\ "type=\" text/javascript\ "></script>- > ";
If it's an HTML file, comment out the specific JavaScript code
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);
}
}
}

/*
* F files that will modify specific content
* SRC will be replaced by the content
* DST will be replaced with the contents of the layer
*/
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;
}
}
}


There is a way to delete the line through the Shell JS code, very simple and convenient, than I write Java convenient 100 times times, I hate Java

Copy Code code as follows:

Find. -name "*.html" |xargs grep-l "Jsapi" |xargs sed-i '/jsapi/d '

The other way is to break the net, or use Ie,firefox offline browsing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.