简体   繁体   English

检查网络服务是否为空

[英]check webservice if Empty

I have a web service and I wanna know if it's empty or not?? 我有一个Web服务,我想知道它是否为空? I wanna way to do this .. how to send request and print the response in a textView ?? 我想这样做的方式..如何发送请求并在textView中打印响应? I know gotta use HttpConnetion but I'm confused about this class!! 我知道一定要使用HttpConnetion但是我对此类感到困惑!

DefaultHttpClient httpClient = new DefaultHttpClient(); DefaultHttpClient httpClient =新的DefaultHttpClient(); HttpGet httpPost = new HttpGet(urlName); HttpGet httpPost =新的HttpGet(urlName);

       HttpResponse httpResponse = httpClient.execute(httpPost);
       HttpEntity httpEntity = httpResponse.getEntity();
       inputStream = httpEntity.getContent(); 




       BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8);
       StringBuilder stringBuilder = new StringBuilder();
       String line = null;
       if ((line = reader.readLine()) != null) {
       stringBuilder.append(line + "\n");
       Data.servContent=stringBuilder.toString();
       }

       line = reader.readLine();
       inputStream.close();
      } catch (UnsupportedEncodingException e) {
           System.err.print("UnsupportedEncodingException: " + e);
       } catch (ClientProtocolException e) {
       System.err.print("ClientProtocolException: " + e);
       } catch (IOException e) {
       System.err.print("IOException: " + e);
       } catch (Exception e) {
       Log.e("Buffer Error", "Error converting result " + e.toString());
       }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM