android为什么只有传递时间格式才报java.io.EOFException错误
private HttpPostUtil mHttp = null;
private void refresh() {
new Thread(new Runnable() {
@Override
public void run() {
try {
mHttp.clearTextParameter();
mHttp.setUrl(ConstantInfo.EVENT_QUERY_LIST_URL);
mHttp.addTextParameter("item", mEventInfo);
LogUtil.d("获取查询的条件", mEventInfo.getEventState());
mHttp.addTextParameter("pageSize", pageSize);
LogUtil.d("获取查询的条件2", mEventInfo.getEndTime());
mHttp.addTextParameter("pageIndex", pageIndex);
String result = mHttp.connect();
LogUtil.d("获取查询的条件3", result);
eventList = GsonUtil.fromJsonList(result, EventInfo.class);
LogUtil.d("获取查询的条件4", eventList);
sendEmptyMessage(mHandler, ErrorCode.SUCCESS);
} catch (ConnectException e) {
LogUtil.e(TAG, e.toString());
sendEmptyMessage(mHandler, ErrorCode.ERROR_NETWORK);
} catch (Exception e) {
LogUtil.e(TAG, e.toString());
LogUtil.d("获取查询的条件5",e.toString());
sendEmptyMessage(mHandler, ErrorCode.ERROR_SERVICE);
}
}
}).start();
}
public String connect() throws IOException {
//中断连接
this.isInterrupt = false;
try {
initConnection();
} catch (Exception e) {
LogUtil.e(TAG, e.toString());
throw new ConnectException("连接服务器失败,可能设备没网络");
}
conn.connect();
//写入流
OutputStream os = conn.getOutputStream();
LogUtil.d("获取的流是多少", os);
mDataOutputStream = new DataOutputStream(os);
LogUtil.d("获取的流是多少2", mDataOutputStream);
//写入
writeStringParams();
writeFileParams();
paramsEnd();
LogUtil.d("获取的状态码是多少", conn.getResponseCode());
//连接成功的标志200
if(conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
//获取输入的流
InputStream in = conn.getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
int b = -1;
while ((b = in.read()) > -1) {
out.write(b);
}
byte[] arr = out.toByteArray();
out.close();
in.close();
mDataOutputStream.close();
os.close();
disconnect();
LogUtil.d("获取的字节的数组", arr);
String result = new String(arr);
if(TextUtils.isEmpty(result)) {
throw new NullPointerException("服务器返回值为空");
}
LogUtil.d(TAG, result);
return result;
} else {
LogUtil.e(TAG , "响应码==> " + conn.getResponseCode());
throw new IOException("服务器异常");
}
}