今天在采集错误时,发现有一个诡异异常:
com.android.internal.os.LoggingPrintStream.println(LoggingPrintStream.java:298)
抛出空指针异常,NullPointerException,奇怪了,我没有调用这个方法啊,只是
System.out.println()出字符串信息?难不成println空指针字符串会出错为了验证这个问题,我特地写了如下代码再onCreate()里:
String responseBody = null;
System.out.println(responseBody);
当启动的时候你发现什么了,果然是应用程序异常退出,然后看到logcat里报空指针错误,天啊!怎么会这样。看了一下源码,
294 @Override
295 public synchronized void println(String s) {
296 if (builder.length() == 0) {
297 // Optimization for a simple println.
298 int length = s.length();
299
300 int start = 0;
....
天啊,这段代码竟然没有判断s是否为空指针而直接取length了,难怪会报异常,希望android源码开发者们能看到这个问题,并且改正,要不然每一次在System.out.println()都要判断是否为空指针是多么可怕的事情啊!
分享到:
相关推荐
package andr.liu; import android.app.Activity;... System.out.println("123ww565"); System.out.println("www"); System.out.println("123565"); } OnClickListener operator1=new View.OnClickLis
System.out.println("create a DataBase"); // execSQL函数用于执行sql语句 db.execSQL("create table person(personid integer primary key autoincrement, name varchar(20),age integer,tel varchar(20))"); ...
// System.out.println("OnItemClick path1:"+path); if (temp.equals("..")) path = getSubDir(path); else if (path.equals("/")) path = path + temp; else path = path + "/" + temp; // System.out....
System.out.println("onPageScrolled OnRearrangeListener.onRearrange from=" oldIndex ", to=" newIndex); String item = mAdapter.getItem(oldIndex); mAdapter.setNotifyOnChange(false)...
HeapUnit Test library to introspecting your Java heap via heap dumps. HeapUnit can capture heap dump of own JVM scan content of dump reconstruct Java ... System.out.println(i.rehydrate() (open ?
System.out.println("正在进入切换摄像头模块"); //切换前后摄像头 int cameraCount = 0; Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); cameraCount = Camera.getNumberOfCameras();//...
... import android.app.Dialog; import android.content.Context; import android.graphics.drawable.AnimationDrawable;... System.out.println("localStringBuilder=="+localStringBuilder); } } }
System.out.println(str.size()); } lv = (ListView) this.findViewById(R.id.lv); adapter=new MyAdapter(); lv.setAdapter(adapter); b_all = (Button) this.findViewById(R.id.b_all);//布局对应...
System.out.println("screenWidth:"+screenWidth+"=="+screenHeight); Options options = new Options(); //加载边框 一定options.inJustDecodeBounds = true; options.inJustDecodeBounds = true; Bitmap...
System.out.println("hands moved"); Log.d(TAG, "hands moved in calling activity"); if (localWakeLock.isHeld()) { return; } else { localWakeLock.setReferenceCounted(false); localWakeLock.release...
04 System.out.println(userName+"-"+password); 05 DataOutputStream dos = new DataOutputStream(response.getOutputStream()); 06 if (userName != null && password != null) { 07 if (userName.length() ...
System.out.println("myURL=" myURL); URLConnection conn = myURL.openConnection(); //建立联机 conn.connect(); InputStream is = conn.getInputStream(); //InputStream 下载文件 if (is == null) /...
// System.out.println(t4); return t4; } catch (BadHanyuPinyinOutputFormatCombination e1) { e1.printStackTrace(); } return t4; } public Runnable updata = new Runnable() { public void run()...
System.out.println(phoneNumber); }while(phones.moveToNext()); } } str+="\r\n"; } while (cur.moveToNext()); } } 4.读文件代码 try { File file = new File("/sdcard/test.txt"); ...
System.out.println("currentItem: " + currentItem); currentItem = (currentItem + 1) % imageViews.size(); handler.obtainMessage().sendToTarget(); } } } /*** * 当viewPager...
System.out.println(response); String[] items = response.split(";"); String id = items[0].substring(items[0].indexOf("=")+1);//服务返回绑定该文件的资源id String position = items[1]....
System.out.println("SDKVersion = " + SDKVersion); DatePicker dp = findDatePicker((ViewGroup) mdialog.getWindow() .getDecorView());// 设置弹出年月日 if (dp != null) { if (SDKVersion ) { ...
从Java到Kotlin 从Java到Kotlin-Java到Kotlin的备忘单 打印到控制台 Java System . out . print( " Amit Shekhar " ... System . out . println( " Amit Shekhar " );...println ( " Amit Shekhar " ) ...otherName = null ;
System . out . print( " Amit Shekhar " ); System . out . println( " Amit Shekhar " ); Kotlin print ( " Amit Shekhar " ) println ( " Amit Shekhar " ) 常量和变量 Java String name = " Amit Shekhar " ; ...
170 System.out.println("-yes-"+i); 171 mSelectedPoint = mPoints[i]; 172 } 173 } 174 break; 175 case MotionEvent.ACTION_MOVE: 176 if ( null != mSelectedPoint) 177 { 178 // ...