why Exception occure in HttpPost?
<p>I am sending value through using HTTP-post but an exception occur  my code is as:-</p>

<pre><code>public static InputStream SendDetails(String senderEmail,String senderName,String senderPhone,String comment )
{
     if(item != null)
        {
            url = constants.STATEURL + item.getListingid().toString()+"/contact";//?access_token=0|V1CALGARY|e98984a4c954fa1d78e3be626ad81a1d&amp;mode=map";
        }
        else if(itemsavedfromdb != null)
        {
            url = constants.STATEURL + itemsavedfromdb.getListingid().toString()+"/contact";//?access_token=0|V1CALGARY|e98984a4c954fa1d78e3be626ad81a1d&amp;mode=map";
        }
        else if(itemrecentfromdb != null)
        {
            url = constants.STATEURL + itemrecentfromdb.getListingid().toString()+"/contact";//?access_token=0|V1CALGARY|e98984a4c954fa1d78e3be626ad81a1d&amp;mode=map";
        }

        List&lt;BasicNameValuePair&gt; nameValuePairs = new ArrayList&lt;BasicNameValuePair&gt;();
        nameValuePairs.add(new BasicNameValuePair("access_token",constants.accesstokenstate));

        nameValuePairs.add(new BasicNameValuePair("mode","map"));

        nameValuePairs.add(new BasicNameValuePair("senderEmail",senderEmail));

        nameValuePairs.add(new BasicNameValuePair("senderName",senderName));

        nameValuePairs.add(new BasicNameValuePair("senderPhone",senderPhone));

        nameValuePairs.add(new BasicNameValuePair("comment",comment));  

        HttpPost request = new HttpPost(url);
        request.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpClient client = new DefaultHttpClient();
        HttpResponse response = client.execute(request);

        return response.getEntity().getContent();
</code></pre>

<p>}
 this method called by as:-</p>

<pre><code>            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            mailHandler myhandler = new mailHandler();
            xr.setContentHandler(myhandler);
            String mailID = youremail.getText().toString();

            if(mailID != null &amp;&amp; !mailID.equalsIgnoreCase("") )
             {
               System.out.println("1");
               ios = SendDetails(mailID,yourName.getText().toString(),yourPhoneNo.getText().toString(),yourMessage.getText().toString());   
               System.out.println("ios-----"+ios);
               String strResponse = convertStreamToString(ios);
                   System.out.println("response"+strResponse);                 
               xr.parse(new InputSource(ios));

                resultmail = myhandler.emailresultdata();

                customizeDialog = new CustomizeDialog(PropertyDetail.this);  
                customizeDialog.setTitle("Success");  
                customizeDialog.setMessage("Email send successfully");  
                customizeDialog.show();
</code></pre>

<p>Excepion occure  above code due to which data not successfully send</p>

<p>follwing is stacktrace:-</p>

<pre><code>07-03 09:02:15.264: WARN/System.err(491): java.io.IOException: Attempted read on closed stream.
07-03 09:02:15.275: WARN/System.err(491):     at org.apache.http.conn.EofSensorInputStream.isReadAllowed(EofSensorInputStream.java:127)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:176)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:516)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:479)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:318)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:275)
   07-03 09:02:15.275: WARN/System.err(491):     at com.rentfaster.home.PropertyDetail.onClick(PropertyDetail.java:1623)
   07-03 09:02:15.275: WARN/System.err(491):     at java.lang.reflect.Method.invokeNative(Native  Method)
   07-03 09:02:15.275: WARN/System.err(491):     at java.lang.reflect.Method.invoke(Method.java:507)
    07-03 09:02:15.275: WARN/System.err(491):     at android.view.View$1.onClick(View.java:2139)
    07-03 09:02:15.284: WARN/System.err(491):     at android.view.View.performClick(View.java:2485)
    07-03 09:02:15.284: WARN/System.err(491):     at android.view.View$PerformClick.run(View.java:9080)
    07-03 09:02:15.284: WARN/System.err(491):     at android.os.Handler.handleCallback(Handler.java:587)
    07-03 09:02:15.284: WARN/System.err(491):     at android.os.Handler.dispatchMessage(Handler.java:92)
    07-03 09:02:15.284: WARN/System.err(491):     at android.os.Looper.loop(Looper.java:130)
     07-03 09:02:15.284: WARN/System.err(491):     at android.app.ActivityThread.main(ActivityThread.java:3683)
   07-03 09:02:15.284: WARN/System.err(491):     at java.lang.reflect.Method.invokeNative(Native Method)
   07-03 09:02:15.284: WARN/System.err(491):     at java.lang.reflect.Method.invoke(Method.java:507)
   07-03 09:02:15.284: WARN/System.err(491):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   07-03 09:02:15.294: WARN/System.err(491):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   07-03 09:02:15.294: WARN/System.err(491):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>and my  convertStreamToString methos is as:-</p>

<pre><code>private static String convertStreamToString(InputStream is) {

    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();

    String line = null;
    try {
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return sb.toString();
}
</code></pre>

<p>Any one suggest me where am I wrong and what's right way to do this.</p>
