title: I am getting exception like Attempted read on close stream in following code
body: <p>IN MainActivity.java </p>
  
  <pre><code>DefaultHttpClient client = new DefaultHttpClient();
  HttpPost post = new HttpPost("http://192.168.5.10/ijoomer_development/index.php?option=com_ijoomer&amp;plg_name=jomsocial&amp;pview=user&amp;ptask=login&amp;tmpl=component");
  StringBuffer strBuffer = new StringBuffer("&lt;data&gt;&lt;username&gt;" + username + "&lt;/username&gt;&lt;password&gt;" + password + "&lt;/password&gt;&lt;lat&gt;" + lat +"&lt;/lat&gt;&lt;long&gt;"+ longi +"&lt;/long&gt;&lt;/data&gt;");
  StringEntity strEntity = new StringEntity(strBuffer.toString());
  post.setEntity(strEntity);
  HttpResponse response = client.execute(post);
  
  InputStream in = response.getEntity().getContent();
  
  MainActivity mActivity = new MainActivity();
  System.out.println(mActivity.convertStreamToString(in));
  
  demoHandler = new DemoHandler();
  ArrayList&lt;UserBean&gt; users = demoHandler.parse(in);
  Log.i("VALUE OF USER",""+users);
  </code></pre>
  
  <p>IN DemoHandler.java</p>
  
  <pre><code>public ArrayList&lt;UserBean&gt; parse(InputStream in) {
      try {
          SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
          parser.parse(in, this);
  
      } catch (ParserConfigurationException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (SAXException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      return records;
  }
  
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
  {
      data.replace(0, data.length(), "");
  
      if(localName.equalsIgnoreCase(ROOT_TAG))
          bean = new UserBean();
  }
  
  public void characters(char[] ch, int start, int length) throws SAXException {
      data.append(ch, start, length);
  }
  
  @Override
  public void endElement(String uri, String localName, String qName) throws SAXException
  {
      if(localName.equalsIgnoreCase(TAG_USERNAME))
          bean.username = data.toString().trim();
      else if(localName.equalsIgnoreCase(TAG_PASSWORD))
          bean.password = data.toString().trim();
      else if(localName.equalsIgnoreCase(TAG_LAT))
          bean.lat = data.toString().trim();
      else if(localName.equalsIgnoreCase(TAG_LONG))
          records.add(bean);
  }
  
   public String convertStreamToString(InputStream in) throws IOException {
      if (in != null) {
          writer = new StringWriter();
  
         char[] buffer = new char[1024];
         try {
             Reader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
              int n;
              while ((n = reader.read(buffer)) != -1) {
                  writer.write(buffer, 0, n);
              }
              } finally {
                  in.close();
              }
              return writer.toString();
          } else {       
              return "";
          }
      }
  }
  </code></pre>
  
  <p>I am getting error at line <code>ArrayList&lt;UserBean&gt; users = demoHandler.parse(in);</code> in MainActivity.java</p>
  
  <p>I am getting another error at line <code>parser.parse(in, this);</code> in DemoHandler.java</p>
  
  <p>Exception:</p>
  
  <pre><code>03-19 11:25:03.108: WARN/ExpatReader(297): DTD handlers aren't supported.
  03-19 11:25:03.108: WARN/System.err(297): java.io.IOException: Attempted read on closed stream.
  03-19 11:25:03.169: WARN/System.err(297):     at org.apache.http.conn.EofSensorInputStream.isReadAllowed(EofSensorInputStream.java:127)
  03-19 11:25:03.169: WARN/System.err(297):     at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:176)
  03-19 11:25:03.169: WARN/System.err(297):     at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:504)
  03-19 11:25:03.169: WARN/System.err(297):     at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467)
  03-19 11:25:03.169: WARN/System.err(297):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:329)
  03-19 11:25:03.169: WARN/System.err(297):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:286)
  03-19 11:25:03.209: WARN/System.err(297):     at javax.xml.parsers.SAXParser.parse(SAXParser.java:361)
  03-19 11:25:03.219: WARN/System.err(297):     at javax.xml.parsers.SAXParser.parse(SAXParser.java:240)
  03-19 11:25:03.219: WARN/System.err(297):     at com.demo.parsing.DemoHandler.parse(DemoHandler.java:69)
  03-19 11:25:03.219: WARN/System.err(297):     at com.demo.parsing.MainActivity$1.onClick(MainActivity.java:119)
  03-19 11:25:03.219: WARN/System.err(297):     at android.view.View.performClick(View.java:2364)
  03-19 11:25:03.219: WARN/System.err(297):     at android.view.View.onTouchEvent(View.java:4179)
  03-19 11:25:03.219: WARN/System.err(297):     at android.widget.TextView.onTouchEvent(TextView.java:6540)
  03-19 11:25:03.219: WARN/System.err(297):     at android.view.View.dispatchTouchEvent(View.java:3709)
  03-19 11:25:03.219: WARN/System.err(297):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  03-19 11:25:03.219: WARN/System.err(297):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  03-19 11:25:03.219: WARN/System.err(297):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  03-19 11:25:03.219: WARN/System.err(297):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
  03-19 11:25:03.219: WARN/System.err(297):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
  03-19 11:25:03.219: WARN/System.err(297):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
  03-19 11:25:03.219: WARN/System.err(297):     at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
  03-19 11:25:03.219: WARN/System.err(297):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
  03-19 11:25:03.239: WARN/System.err(297):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
  03-19 11:25:03.239: WARN/System.err(297):     at android.os.Handler.dispatchMessage(Handler.java:99)
  03-19 11:25:03.239: WARN/System.err(297):     at android.os.Looper.loop(Looper.java:123)
  03-19 11:25:03.239: WARN/System.err(297):     at android.app.ActivityThread.main(ActivityThread.java:4363)
  03-19 11:25:03.239: WARN/System.err(297):     at java.lang.reflect.Method.invokeNative(Native Method)
  03-19 11:25:03.239: WARN/System.err(297):     at java.lang.reflect.Method.invoke(Method.java:521)
  03-19 11:25:03.239: WARN/System.err(297):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  03-19 11:25:03.239: WARN/System.err(297):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  03-19 11:25:03.329: WARN/System.err(297):     at dalvik.system.NativeStart.main(Native Method)
  03-19 11:25:03.329: INFO/VALUE OF USER(297): []
  </code></pre>