在黑莓中阅读epub文件

你能告诉我一个启动黑莓Epub阅读器应用程序的提示吗?

我想要最简单的方法,是否有任何浏览器或UI组件可以阅读&显示它?

我想从服务器下载它然后查看它给用户阅读它.

最佳答案 几天前,一个Epub读者库被添加了
here,我试着用它,但是它有一些困难,它只能从资源打开Epubs,但不能从文件系统打开,所以我决定下载源代码并做一些改编.

首先,我写了一个小函数,它将Epub文件作为流打开:

public static InputStream GetFileAsStream(String fName) {
    FileConnection fconn = null;
    DataInputStream is = null;
    try {
        fconn = (FileConnection) Connector
                .open(fName, Connector.READ_WRITE);
        is = fconn.openDataInputStream();

    } catch (IOException e) {
        System.out.println(e.getMessage());
    return is;

然后,我替换了在com.omt.epubreader.domain.epub.java中打开文件的调用,所以它变成了这样:

public Book getBook(String url)
{
    InputStream in = ConnectionController.GetFileAsStream(url);

    ...
    return book;
}

之后,我可以成功读取文件,但是出现了一个问题,它无法读取这些部分,即.html文件,所以我在发现问题之前进入了一个简短的调试会话,无论谁写了这个库,将读取.html文件名的代码留空,在com.omt.epubreader.parser.NcxParser中它是这样的:

private void getBookNcxInfo()
{
    ...

    if(pars.getEventType() == XmlPullParser.START_TAG && 
                    pars.getName().toLowerCase().equals(TAG_CONTENT))
    {
        if(pars.getAttributeCount()>0)
        {

        }
    }

    ...
}

我刚刚将这一行添加到if子句中:

contentDataFileName.addElement(pars.getAttributeValue("", "src"));

之后,它运作得非常完美.

点赞