问题
将返回数据由string类型转换为int类型报错
java.lang.NumberFormatException: For input string: ""
at java.lang.Integer.parseInt(Integer.java:627)
at java.lang.Integer.parseInt(Integer.java:650)
at
详细问题
2022-09-25 16:41:17.074 5182-5437/com.example.electronicmall E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.example.electronicmall, PID: 5182
java.lang.NumberFormatException: For input string: ""
at java.lang.Integer.parseInt(Integer.java:627)
at java.lang.Integer.parseInt(Integer.java:650)
at com.example.electronicmall.test.Admin.AdminMineDetailActivity$5$1$1$1$1.onResponse(AdminMineDetailActivity.java:333)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:168)
at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:929)
解决方案
对于返回数据, 确保非空后方可使用parseInt()方法转换为int数据类型
原因
由于返回数据为空, 对于空字符串无法通过parseInt()方法转换为int数据类型
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈