8 Replies Latest reply: Feb 7, 2008 7:33 AM by 807603 RSS

    How to remove White Space in StringBuffer?


      I am constructing a response in xml format and append the string to the StringBuffer. The following result occurs randomly when I am retrieving the values.
            <                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        emp name="emp1"/>
      Very large white space is between *<* and emp. The code is
      resBuff.append("      <emp name=\"" + item.getEmpName().trim() + "\"/>\n");
      The required response is
            <emp id="173"/>
            <emp name="xxx"/>
            <emp dept="dpt1"/>
            <emp desig="se"/>
            <emp ph="xxxxx"/>
      Can anyone give me the pointer?