I am Using this Library For AndroidPdfViewer https://github.com/barteksc/AndroidPdfViewer
E/PDFView: load pdf error
java.lang.NullPointerException
at com.github.barteksc.pdfviewer.util.Util.toByteArray(Util.java:36)
at com.github.barteksc.pdfviewer.source.InputStreamSource.createDocument(InputStreamSource.java:37)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:49)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:25)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Here I am Getting nullPointer Exception on This Line.
inputStream=new BufferedInputStream(urlConnection.getInputStream());
It seems that this is not a library error, because it's a NullPointer raising due to the null parameter. your PDFViwer is unable to open the file hence it's throwing null pointer exception. you can check you code for the cause. you should follow the best practices to prevent such situations. Check the connection first, it should not be null. you can check with
?
ternary operator as given below.