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