本文主要是介绍System.ArrayCopy , NullPointerException异常,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
byte[] partByte = null;if ((len =fileInputStream.read(buffer)) != -1) {System.arraycopy(buffer, 0 , partByte , 0, len);
报错,因为partByte是null,而后改成:
byte[] partByte = null;int len; // int count=0;try {if ((len =fileInputStream.read(buffer)) != -1) {if (len != 1024*1024) {byte[] bytes = new byte[len];System.arraycopy(buffer, 0 , bytes, 0, len); partByte = bytes;
参考
String[] a = {"a","b","c","d","e"}; String[] b = null; //System.arraycopy(a, 0, b, 0, 5); //java.lang.NullPointerException b = Arrays.copyOf(a, 5); //b={"a","b","c","d","e"}
这篇关于System.ArrayCopy , NullPointerException异常的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!