【发布时间】:2012-04-16 22:34:48
【问题描述】:
我正在使用http://www.siegmann.nl/epublib 来读取 epub 文件。我的代码在下面提到。
try {
book = epubReader.readEpub(new FileInputStream("/sdcard/EpubTesting.epub"));
Resource res;
Spine contents = book.getSpine();
List<SpineReference> spinelist = contents.getSpineReferences();
StringBuilder string = new StringBuilder();
String line = null;
int count = spinelist.size();
for (int i=0;i<count;i++){
res = contents.getResource(i);
try {
InputStream is = res.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
try {
while ((line = reader.readLine()) != null) {
linez = (string.append(line+"\n")).toString();
}
} catch (IOException e) {e.printStackTrace();}
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println(linez);
s1.loadDataWithBaseURL("/sdcard/",linez, "text/html", "UTF-8",null);
}catch (FileNotFoundException e) {
Toast.makeText(mContext, "File not found.", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(mContext, "IO Exception.", Toast.LENGTH_SHORT).show();
}
也试过了
s1.loadDataWithBaseURL("",linez, "text/html", "UTF-8",null);
s1.loadDataWithBaseURL("file://mnt/sdcard/",linez, "text/html", "UTF-8",null);
但结果是 sifar。请告诉我我必须做什么才能显示文件中包含的图像。我已经通过常见问题解答说创建android.webkit.WebView 的子类,它重载loadUrl(String) 方法,以便从书而不是互联网加载图像。但是直到我不知道他们提取文件的位置,我怎样才能找到路径。请告诉我。我很迷茫。提前致谢。
【问题讨论】:
标签: java android android-layout android-emulator epub