如题  代码如下public static String requestPost(String linkAddress, int timeout) {
  String result = null;
  try {
   URL url = new URL(linkAddress); 
   setProxy();
   HttpURLConnection conn = (HttpURLConnection) url.openConnection();
   conn.setConnectTimeout(timeout * 1000);
   conn.connect();
   int state = conn.getResponseCode();
   System.out.println(state);
   System.out.println(linkAddress);
   if (state == HttpURLConnection.HTTP_OK) {
    InputStream in = conn.getInputStream();
    System.out.println("$$$$$$"+in.available());
    BufferedReader reader = new BufferedReader(new InputStreamReader(in, HTTP.UTF_8));
    String line = null;
    while ((line = reader.readLine()) != null) {
     if(result==null){
      result=line;
     }else{
     result += line;
     }
    }
   }
  } catch (MalformedURLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  return result;
}
服务器端返回的state是200  也就是访问是成功的  但是为什么服务器端的流得不到呢?   流确实存在  我用手机就可以正常运行  ,而用模拟器就不行  ,求解?  其中setProxy()是设置代理  通过代理的方式访问的

解决方案 »

  1.   

    问题是我现在没有android手机。。而且这个小模块现在又点bug  分到我头上了  这个怎么办? 连接成功获得的流怎么可能是空的呢。
      

  2.   

    所有功能都是正常的   int state = conn.getResponseCode();
    state=200   
      

  3.   

    LZ,这个问题你解决没啊,我的问题跟你相反,我在模拟上可以获得数据,在手机上得不到,返回code也是200
    能告诉我下是什么原因吗
      

  4.   

    我也得不到inputstream流啊