好的,我正在回答我自己的问题。我使用了 Panos 的答案:https ://stackoverflow.com/a/13357785/1572408
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
return sb.toString();
}
在onCreate()
:
File fl = new File(myLesson);
FileInputStream fin;
fin = new FileInputStream(fl);
String ret = convertStreamToString(fin);
ret = ret.replace("<body>","<body align='right' style='font-size:14pt;>");
webView.loadDataWithBaseURL("file:///android_asset/", ret, "text/html",
"UTF-8", "");