无法在BufferedReader中解析方法getBody()

时间:2017-06-30 13:44:35

标签: java android retrofit2 bufferedreader

我想使用 Retrofit 2.0 将数据插入我的服务器我创建了ApiClient并使用Fragment代替Activity ... 我的程序中只有一个错误 这是我得到错误的类

 api.insertUser(
            etName.getText().toString(),
            etAge.getText().toString(),
            etCity.getText().toString(),
            etMob.getText().toString(),

            new Callback<Response>() {
                @Override
                public void onResponse(Call<Response> result, Response<Response> response) {

                    BufferedReader reader = null;

                    //An string to store output from the server
                    String output = "";

                    try {
                        //Initializing buffered reader


                        reader = new BufferedReader(new InputStreamReader(result.getBody().in()));

                        //Reading the output in the string
                        output = reader.readLine();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    //Displaying the output as a toast
                    Toast.makeText(getActivity(), output, Toast.LENGTH_LONG).show();

                }

请帮助我,我错了?

0 个答案:

没有答案