Android reference documentation local open slow, JAVA solution, androidjava

Source: Internet
Author: User

Android reference documentation local open slow, JAVA solution, androidjava

The Android Develop document is clearly downloaded locally, but it is still very difficult to open in the browser, because the html document contains links and scripts linked to the Google server.

There are many solutions on the Internet, one of which is to delete all links and scripts linked to the Google server.

I can't delete the modified css code of the JAVA code I downloaded online. Later I read the code and found some bugs.

<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">

The following is a JAVA code solution that I modified by referring to other people's code. The difference with other people's JAVA code is that they can completely delete all links to Google server links and scripts.

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) {// absolute path File = new file ("G:/Android Docs"); searchDir Ecloud (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 = \" http://www.google.com/jsapi\ "type = \" text/javascript \ "> </script> "; string src3 = "<script src = \" 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 = ""; // matches the corresponding String and replaces annotation (f, src, dst) with "" (empty String); 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; t Ry {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 ;}}}

 

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.