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 7416757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:33:41+00:00 2026-05-29T07:33:41+00:00

I’m trying to create an ePub file in android. Below is my source code.

  • 0

I’m trying to create an ePub file in android.

Below is my source code.

But I’m getting fileNotFoundException at

epubWriter.write(book, new FileOutputStream("test1_book1.epub"));

I’ve put the cover.png and test1.html in assets folder.

Is corresponding css file is compulsory to build an ePub file?

I’m absolute beginner to ePub development so any help/suggestion would be appreciated.

CreateEPub.java

public class CreateEPub extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        AssetManager assetManager = getAssets();

        try {
            Book book = new Book();
            book.getMetadata().addTitle("Epub test book 1");
            book.getMetadata().addAuthor(new Author("Joe", "Tester"));
            InputStream is = assetManager.open("cover.png");
            book.getMetadata().setCoverImage(new Resource(is, "cover.png"));
            // Add Chapter 1
            InputStream is1 = assetManager.open("test1.html");
            book.addSection("Introduction", new Resource(is1, "chapter1.html"));

            EpubWriter epubWriter = new EpubWriter();
            epubWriter.write(book, new FileOutputStream("test1_book1.epub"));
            Log.v("ePub", "Created");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

EDIT

From various suggestions, Now I’m able to create a file but that is not in proper format I guess as when I pull that file from device and try to view it, it doesn’t open giving error that It is not a zip file.

LogCat

java.lang.NullPointerException
at org.kxml2.io.KXmlSerializer.attribute(KXmlSerializer.java:473)
at nl.siegmann.epublib.epub.PackageDocumentMetadataWriter.writeMetaData(PackageDocumentMetadataWriter.java:93)
at nl.siegmann.epublib.epub.PackageDocumentWriter.write(PackageDocumentWriter.java:45)
at nl.siegmann.epublib.epub.EpubWriter.writePackageDocument(EpubWriter.java:112)
0at nl.siegmann.epublib.epub.EpubWriter.write(EpubWriter.java:53)
at com.createepub.CreateEPub.onCreate(CreateEPub.java:93)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
0at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

NOTE : CreateEPub.java:93 referes to epubWriter.write(book, out);

  • 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-29T07:33:42+00:00Added an answer on May 29, 2026 at 7:33 am

    You can write files only to Internal Storage (device memory) or External Storage (the SD card), see data-storage. Simply opening a FileOutputStream with an arbitrary file name won’t work since that file system is read-only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.