本文介绍了为什么ByteArrayOutputStream有时让我空指针异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当加载图片到字节[]在智能手机应用有时ByteArrayOutputStream给我的NullPointerException任何解释?
位图BM = BitmapFactory.de codeFILE(路径);
的System.out.println(!位图+ BM = NULL);
ByteArrayOutputStream缓冲区=新ByteArrayOutputStream();
bm.com preSS(比较pressFormat.JPEG,100,缓冲);
解决方案
您确定这是ByteArrayOutputStream这是给你的NullPointerException异常?
抑或是在bm.com preSS发生了什么? BM可以为null - 很可能是由于你在一个无效的路径传递
When loading a picture into byte[] in smartphone app sometimes ByteArrayOutputStream gives me nullpointerexception any explanation?
Bitmap bm = BitmapFactory.decodeFile(path);
System.out.println("BITMAP: "+bm != null);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
bm.compress(CompressFormat.JPEG, 100, buffer);
解决方案
Are you sure it's ByteArrayOutputStream that's giving you the NullPointerException?
Or is it happening at bm.compress? bm can be null - likely due to you passing in an invalid path.
这篇关于为什么ByteArrayOutputStream有时让我空指针异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!