Android docs4.3API

Source: Internet
Author: User

Classes found on the internet accelerate access to the Android docs API, mainly because loading js files on the internet is slow, and loading google fonts is slow!

Import java. io. bufferedReader; import java. io. bufferedWriter; import java. io. file; import java. io. fileFilter; import java. io. fileNotFoundException; import java. io. fileReader; import java. io. fileWriter; import java. io. IOException; import java. util. map; import java. util. UUID; public class AndroidDoc {private static final String ANDROID_SDK_HOME = "ANDROID_SDK_HOME "; private static final String TAG = "<script src = \"\ "type = \" text/javascript \ "> </script>"; // private static final String TAG ="
 "; Private static String androidSDKHome; public static void main (String [] args) {Map
Map = System. getenv (); androidSDKHome = map. get (ANDROID_SDK_HOME); if (androidSDKHome! = Null) {System. out. println ("Detected the Android SDK Installation path:" + androidSDKHome); File docs = new File (androidSDKHome + "\ docs"); System. out. println ("It will take several minutes, please wait... "); traverse (docs); System. out. println ("Operation Down !!! Now you can visit Android Doc without waiting... ");} else {System. out. println (" Please configure the Android SDK Environment variable (ANDROID_SDK_HOME )! ") ;}}/*** Traverse the docs directory under the Android SDK installation directory ** @ param dir */private static void traverse (File dir) {if (dir. isDirectory () {File [] files = dir. listFiles (new FileFilter () {@ Override public boolean accept (File file) {if (file. isFile () & file. getName (). endsWith (". html ") {BufferedReader reader = null; try {reader = new BufferedReader (new FileReader (file); String buffer; while (buffer = reader. r EadLine ())! = Null) {if (buffer. trim (). inclusignorecase (TAG) {return true ;}} catch (Exception e) {e. printStackTrace ();} finally {try {reader. close ();} catch (IOException e) {e. printStackTrace () ;}} else if (file. isDirectory () {return true;} return false ;}); for (File file: files) {if (file. isDirectory () {System. out. println ("Scanning Folder:" + file. getAbsolutePath (); traverse (file );} Else {doChange (file );}}}} /*** annotate a line of Javascript code in html ** @ param file * @ return */private static boolean doChange (File file) {System. out. println ("Extracting File:" + file. getAbsolutePath () + "... "); String desPath = file. getParent () + "\" + UUID. randomUUID (). toString () + ". html "; File des = new File (desPath); BufferedReader reader = null; BufferedWriter writer = null; try {des. createNe WFile (); reader = new BufferedReader (new FileReader (file); writer = new BufferedWriter (new FileWriter (des); String buffer; while (buffer = reader. readLine ())! = Null) {if (buffer. trim (). equalsIgnoreCase (TAG) {buffer ="
  ";} Writer. write (buffer + "\ n"); writer. flush ();} return true;} catch (FileNotFoundException e) {e. printStackTrace ();} catch (IOException e) {e. printStackTrace ();} finally {try {reader. close (); writer. close (); file. delete (); des. renameTo (file);} catch (IOException e) {e. printStackTrace () ;}} return false ;}}

Directly compile and run the program. Three lines of comments are replaced by three

There are two reasons for slow loading: loading Google fonts and loading Google JS files.

If you feel trouble directly go to my online disk download, address:

Related Article

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: 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.