Hi everyone i try to show content of epub using epublib. this is my code
File f = new File(Environment.getExternalStorageDirectory() + "/documents/cindersilly.epub");
String path = f.getPath();
FileInputStream epubInputStream = new FileInputStream(f);
Book book = new EpubReader().readEpub(epubInputStream);
wvTest.loadDataWithBaseURL(f.getAbsolutePath(), book.getContents().get(0).getData().toString(), "text/html", "UTF-8", null);
and i get result :
[B@41408d8
what is that? and how to solve this so the content will show on the webview? thanks
You haven't posted enough code to be able to see all the details, but your getData()
method is returning a byte[]
. When you invoke toString()
on an object, it tries to convert it into a String
; but arrays don't have a toString()
that returns anything particularly useful. What you get is a header ([B
) that tells you its type (byte array), and an address that says where in JVM memory it's stored.
If you want to be able to see the contents of the array, you can use Arrays.toString()
to turn it into something more useful. You pass it the byte[]
you've got (in this case, the output of getData()
) and it constructs the String
representation for you. Your code would look like this:
wvTest.loadDataWithBaseURL(f.getAbsolutePath(), Arrays.toString(book.getContents().get(0).getData()), "text/html", "UTF-8", null);
It's also possible you weren't intending it to return a byte[]
at all, in which case your problem is further back in your code.