title: What is the best way to filter the text using stringBuffer in java?
body: <p>Here is the code I wrote for replacing the text. 
  Input text is</p>
  
  <blockquote>
    <p>Apple, Computer</p>
  </blockquote>
  
  <p>expected output is</p>
  
  <blockquote>
    <p>Apple</p>
  </blockquote>
  
  <p>So I have written it like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>import org.apache.commons.lang3.StringUtils;
  
  public class One {
      public static void main(String[] args) {
          one();
      }
  
      private static void one() {
          String fruit = "Apple";
          StringBuffer device = new StringBuffer("Computer");
  
          if (StringUtils.isNotBlank(fruit)) {
              if (device.length() == 0) {
                  device.append(fruit);
  
                  System.out.println("if:: " + device.append(fruit));
  
              }
              else {
                  StringBuffer sss = device.insert(0, fruit + ", ");
  
                  System.out.println(sss);
                  // Apple,Computer
              }
          }
  
          if (StringUtils.isNotBlank(device) &amp;&amp; device.charAt(5) == ',') {
              StringBuffer output = device.delete(5, 14);
              System.out.println(output);
          }
      }
  }
  </code></pre>
  
  <p>is any other way , please suggest</p>