doutizha7526 2018-03-06 13:24
浏览 974

如何解决java.io.EOFException:在android 1的改造服务调用中第1行第1列路径1的输入结束?

I am new to android. I am not getting why this error is coming. Error : java.io.EOFException: End of input at line 1 column 1 path $ W/System.err:at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1393) Please help. This is my code : 1. Pojo

class ProfileEntity implements Parcelable {

@SerializedName("tag")
@Expose
private String tag;
@SerializedName("success")
@Expose
private Integer success;
@SerializedName("error")
@Expose
private Integer error;
@SerializedName("studentId")
@Expose
private String studentId;
@SerializedName("pic_id")
@Expose
private String picId;
@SerializedName("instUrl")
@Expose
private String instUrl;
@SerializedName("course_name")
@Expose
private String courseName;
@SerializedName("batch_name")
@Expose
private String batchName;
@SerializedName("semester_name")
@Expose
private Object semesterName;
@SerializedName("section_name")
@Expose
private String sectionName;
@SerializedName("first_name")
@Expose
private String firstName;
@SerializedName("last_name")
@Expose
private String lastName;
@SerializedName("username")
@Expose
private String username;
@SerializedName("groupname")
@Expose
private String groupname;
@SerializedName("mobile")
@Expose
private String mobile;
@SerializedName("email")
@Expose
private String email;
@SerializedName("dob")
@Expose
private String dob;
@SerializedName("address")
@Expose
private String address;
@SerializedName("dbname")
@Expose
private String dbname;
@SerializedName("Branch_id")
@Expose
private String branchId;
@SerializedName("org_id")
@Expose
private String orgId;
@SerializedName("cyear")
@Expose
private String cyear;
@SerializedName("url")
@Expose
private String url;
@SerializedName("password")
@Expose
private String password;
public final static Creator<ProfileEntity> CREATOR = new Creator<ProfileEntity>() {


    @SuppressWarnings({
            "unchecked"
    })
    public ProfileEntity createFromParcel(Parcel in) {
        return new ProfileEntity(in);
    }

    public ProfileEntity[] newArray(int size) {
        return (new ProfileEntity[size]);
    }
};

protected ProfileEntity(Parcel in) {
    this.tag = ((String) in.readValue((String.class.getClassLoader())));
    this.success = ((Integer) in.readValue((Integer.class.getClassLoader())));
    this.error = ((Integer) in.readValue((Integer.class.getClassLoader())));
    this.studentId = ((String) in.readValue((String.class.getClassLoader())));
    this.picId = ((String) in.readValue((String.class.getClassLoader())));
    this.instUrl = ((String) in.readValue((String.class.getClassLoader())));
    this.courseName = ((String) in.readValue((String.class.getClassLoader())));
    this.batchName = ((String) in.readValue((String.class.getClassLoader())));
    this.semesterName = ((Object) in.readValue((Object.class.getClassLoader())));
    this.sectionName = ((String) in.readValue((String.class.getClassLoader())));
    this.firstName = ((String) in.readValue((String.class.getClassLoader())));
    this.lastName = ((String) in.readValue((String.class.getClassLoader())));
    this.username = ((String) in.readValue((String.class.getClassLoader())));
    this.groupname = ((String) in.readValue((String.class.getClassLoader())));
    this.mobile = ((String) in.readValue((String.class.getClassLoader())));
    this.email = ((String) in.readValue((String.class.getClassLoader())));
    this.dob = ((String) in.readValue((String.class.getClassLoader())));
    this.address = ((String) in.readValue((String.class.getClassLoader())));
    this.dbname = ((String) in.readValue((String.class.getClassLoader())));
    this.branchId = ((String) in.readValue((String.class.getClassLoader())));
    this.orgId = ((String) in.readValue((String.class.getClassLoader())));
    this.cyear = ((String) in.readValue((String.class.getClassLoader())));
    this.url = ((String) in.readValue((String.class.getClassLoader())));
    this.password = ((String) in.readValue((String.class.getClassLoader())));
}

public ProfileEntity() {}

public String getCyear() {
    return cyear;
}

public void setCyear(String cyear) {
    this.cyear = cyear;
}

public String getUrl() {
    return url;
}

public void setUrl(String url) {
    this.url = url;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

public String getOrgId() {
    return orgId;
}

public void setOrgId(String orgId) {
    this.orgId = orgId;
}

public String getBranchId() {
    return branchId;
}

public void setBranchId(String branchId) {
    this.branchId = branchId;
}

public String getDbname() {
    return dbname;
}

public void setDbname(String dbname) {
    this.dbname = dbname;
}

public String getTag() {
    return tag;
}

public void setTag(String tag) {
    this.tag = tag;
}

public Integer getSuccess() {
    return success;
}

public void setSuccess(Integer success) {
    this.success = success;
}

public Integer getError() {
    return error;
}

public void setError(Integer error) {
    this.error = error;
}

public String getStudentId() {
    return studentId;
}

public void setStudentId(String studentId) {
    this.studentId = studentId;
}

public String getPicId() {
    return picId;
}

public void setPicId(String picId) {
    this.picId = picId;
}

public String getInstUrl() {
    return instUrl;
}

public void setInstUrl(String instUrl) {
    this.instUrl = instUrl;
}

public String getCourseName() {
    return courseName;
}

public void setCourseName(String courseName) {
    this.courseName = courseName;
}

public String getBatchName() {
    return batchName;
}

public void setBatchName(String batchName) {
    this.batchName = batchName;
}

public Object getSemesterName() {
    return semesterName;
}

public void setSemesterName(Object semesterName) {
    this.semesterName = semesterName;
}

public String getSectionName() {
    return sectionName;
}

public void setSectionName(String sectionName) {
    this.sectionName = sectionName;
}

public String getFirstName() {
    return firstName;
}

public void setFirstName(String firstName) {
    this.firstName = firstName;
}

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

public String getUsername() {
    return username;
}

public void setUsername(String username) {
    this.username = username;
}

public String getGroupname() {
    return groupname;
}

public void setGroupname(String groupname) {
    this.groupname = groupname;
}

public String getMobile() {
    return mobile;
}

public void setMobile(String mobile) {
    this.mobile = mobile;
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

public String getDob() {
    return dob;
}

public void setDob(String dob) {
    this.dob = dob;
}

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}

public void writeToParcel(Parcel dest, int flags) {
    dest.writeValue(tag);
    dest.writeValue(success);
    dest.writeValue(error);
    dest.writeValue(studentId);
    dest.writeValue(picId);
    dest.writeValue(instUrl);
    dest.writeValue(courseName);
    dest.writeValue(batchName);
    dest.writeValue(semesterName);
    dest.writeValue(sectionName);
    dest.writeValue(firstName);
    dest.writeValue(lastName);
    dest.writeValue(username);
    dest.writeValue(groupname);
    dest.writeValue(mobile);
    dest.writeValue(email);
    dest.writeValue(dob);
    dest.writeValue(address);
    dest.writeValue(dbname);
    dest.writeValue(branchId);
    dest.writeValue(orgId);
    dest.writeValue(cyear);
    dest.writeValue(url);
    dest.writeValue(password);
}

public int describeContents() {
    return 0;
}
}
  1. ApiInterface

        @Headers("Content-Type: application/json")
        @POST("profile.php")
     Call<ProfileEntity> getProfile(@Body ProfileEntity profileEntity);
    

3.Impl

@Override
public void profileCall(ProfileEntity profileEntity) {
 ApiInterface controller = ApiClient.getClient(null).create(ApiInterface.class);
 Call<ProfileEntity> call = controller.getProfile(profileEntity);
    call.enqueue(new Callback<ProfileEntity>() {
        @Override
        public void onResponse(Call<ProfileEntity> call, Response<ProfileEntity> response) {
            if (response.body() != null) {
                ProfileEntity entity = response.body();
                if (entity.getSuccess().toString().equalsIgnoreCase("1")) {
                    profilePresentor.onProfileSuccess(entity);
                } else {
                    profilePresentor.onLogFailedMessage(response.message());
                }

            } else {
                profilePresentor.onLogFailedMessage(response.message());
            }
        }

        @Override
        public void onFailure(Call<ProfileEntity> call, Throwable t) {
            Log.d("FAILURE....",t.toString());
            t.printStackTrace();
            profilePresentor.onProfileFailure(HttpURLConnection.HTTP_INTERNAL_ERROR,"Oops! Something went wrong. Please try again");
        }
    });
}
}

4.ApiClient

 class ApiClient {

public static String BASE_URL = "http://xxxx.xxxxxx.com/appAPI_v2/";

static Retrofit retrofit = null;

public static Retrofit getClient(Map<String, String> headerMap) {
    Gson gson = new GsonBuilder()
            .setLenient()
            .create();

    Retrofit.Builder builder = new Retrofit.Builder();
    builder.baseUrl(BASE_URL);
    builder.addConverterFactory(GsonConverterFactory.create(gson));

    if (headerMap != null) {
        builder.client(getHeader(headerMap));
    } else {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor()
                .setLevel(HttpLoggingInterceptor.Level.BODY);

        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
        httpClient.readTimeout(60, TimeUnit.SECONDS);
        httpClient.connectTimeout(60, TimeUnit.SECONDS);
        if (BuildConfig.DEBUG)
            httpClient.addInterceptor(interceptor);
        builder.client(httpClient.build());
    }
    retrofit = builder.build();
    return retrofit;
}

@NonNull
private static OkHttpClient getHeader(final Map<String, String> header) {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor()
            .setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    httpClient.addInterceptor(new Interceptor() {
        @Override
        public Response intercept(Interceptor.Chain chain) throws IOException {
            Request original = chain.request();

            Request.Builder builder = original.newBuilder();
            for (Map.Entry<String, String> entry : header.entrySet()) {
                builder.addHeader(entry.getKey(), entry.getValue());
            }
            builder.method(original.method(), original.body());
            return chain.proceed(builder.build());
        }
    });
    if (BuildConfig.DEBUG) //hides exposing web service call in logcat when app is released
        httpClient.addInterceptor(interceptor);
    return httpClient.build();
}
}

Thanks in advance.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀