我正在进行Asynch服务器调用,并且偶尔会产生此异常:
End of input at character 0 of
我来到这里:
@Override
protected String doInBackground(String... theParams)
{
String myUrl = theParams[0];
final String user_id = theParams[1];
String charset = "UTF-8";
String response = null;
try
{
String query = String.format("user_id=%s",
URLEncoder.encode( user_id, charset) );
final URL url = new URL( myUrl + "?" + query );
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.connect();
final InputStream is = conn.getInputStream();
final byte[] buffer = new byte[8196];
int readCount;
final StringBuilder builder = new StringBuilder();
while ((readCount = is.read(buffer)) > -1)
{
builder.append(new String(buffer, 0, readCount));
}
response = builder.toString();
}
catch (Exception e)
{
e.getMessage());
}}
有人知道为什么会产生这种情况吗?只是服务器没有响应吗?或其他什么?
谢谢!
答案 0 :(得分:0)
之前已经问过这个问题。
你确定你没有对期待GET的网址发出POST请求吗? 尝试将requestMethod更改为GET并查看其进展情况。
检查这个问题: