Three solutions to slow opening of android help documentation

Source: Internet
Author: User

The reason is that the webpage in the local document has the following js code that will load information online. Just comment it out.

Copy codeThe Code is as follows: <script src = "http://www.google.com/jsapi" type = "text/javascript"> </script>

You can use the java code to comment in batches.

Copy codeThe Code is as follows: package cn. sd. fxd. android;

/*
* Remove the javascript code that requires Internet connection from 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-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 is 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 in which specific content will be modified
* Src replaced content
* Dst replaces the content 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 js Code through shell on the Internet, which is very simple and convenient, 100 times more convenient than the java I wrote, I HATE JAVA

Copy codeThe Code is as follows: find.-name "*. html" | xargs grep-l "jsapi" | xargs sed-I '/jsapi/d'

Another method is to disconnect the network, or use IE or firefox to browse offline.

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.