Andorid studio“方法抛出'java.lang.NullPointerException'异常。无法评估com.android.okhttp.HttpUrl $ Builder.toString()”

时间:2019-09-16 14:55:39

标签: java android

以下代码捕获异常。

try {
            URL url = new URL("http://192.168.0.105/getGif.php?ders=" + dersID);
            URLConnection uc = url.openConnection();
            uc.setConnectTimeout(10000);
            uc.setReadTimeout(10000);
            uc.connect();
            BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
            String line = in.readLine();


            if (line.length() < 0) {
                Toast.makeText(Activity3.this,"It is connect but empty", Toast.LENGTH_LONG).show();

               in.close();
            }else{

                String array[] = line.split(",");
                Toast.makeText(Activity3.this,"It is connect and not empty", Toast.LENGTH_LONG).show();

                in.close();
            }
        }
        catch (IOException e){
            Toast.makeText(Activity3.this,"it is not connect", Toast.LENGTH_LONG).show();
        }  

URL的一部分正在工作,但我认为“ BufferedReader”无法工作,因为出现此错误。方法引发了'java.lang.NullPointerException'异常。调试时无法评估com.android.okhttp.HttpUrl $ Builder.toString()

0 个答案:

没有答案