Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6940855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:48:26+00:00 2026-05-27T12:48:26+00:00

I am unable to figure out why I am stuck at this point although

  • 0

I am unable to figure out why I am stuck at this point although there is no error is my coding. My problem is actually, it doesn’t print out my epub, as well as it just hangs there, till the not responding dialog comes up.

My code is as below:

            package com.epub;

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.List;

    import nl.siegmann.epublib.domain.Book;
    import nl.siegmann.epublib.domain.Resource;
    import nl.siegmann.epublib.domain.Spine;
    import nl.siegmann.epublib.domain.SpineReference;
    import nl.siegmann.epublib.epub.EpubReader;

    import android.app.Activity;
    import android.content.res.AssetManager;
    import android.os.Bundle;
    import android.util.Log;
    import android.webkit.WebView;
    import android.widget.TextView;

    public class EpubReaderActivity extends Activity {
        WebView webView;
        Book book;
        TextView tv;
        String line;
        String linez;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            tv = new TextView(this);
            webView = (WebView)findViewById(R.id.webView);
            webView.getSettings().setJavaScriptEnabled(true);
            AssetManager am = getAssets();
            try {
                InputStream epubInputStream = am.open("testbook.epub");
                book = (new EpubReader()).readEpub(epubInputStream);
            } catch (IOException e) {
                Log.e("epublib", e.getMessage());
            }
            Spine spine = book.getSpine(); 
            List<SpineReference> spineList = spine.getSpineReferences() ;
            int count = spineList.size();
            tv.setText(Integer.toString(count));
            StringBuilder string = new StringBuilder();
            for (int i = 0; count > i; i++) {
                Resource res = spine.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();}

                    //do something with stream
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
            webView.loadData(linez, "text/html", "utf-8");

        }
    }

Mind helping me out on this point?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:48:27+00:00Added an answer on May 27, 2026 at 12:48 pm

    Pu this code inside a thread as this takes time to write the data and load a web view
    Thread is a different part of execution and you will have to wait for few sconds if yor file is large
    you can also put a progress dialog to show loading of webview

               new Thread(){
            public void run() {
                        for (int i = 0; count > i; i++) {
                        Resource res = spine.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();}
    
                    //do something with stream
                } catch (IOException e) {
                    e.printStackTrace();
                }
    
            }
    
         };
        }.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am stuck and unable to figure out why this is the following piece
Hey i am unable to figure out why this xml is not being generated
I'm stuck trying to figure out a solution for the problem below. It's quite
The following code produces no suitable constructor found error. I am unable to figure
This seems like it should be really simple, but I'm unable to figure this
JVM crashes continuously. I can't to figure out what the problem is. I tested
I'm unable to figure out how to do the following... I'm pretty sure it's
Problem fixed! Thanks a lot for the constructive suggestions! I am unable to figure
I hope someone can help me out with this. I can't reproduce this error
I am unable to figure out how to update a milestone in baseCamp using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.