title: Remove "empty" character from String
body: <p>I'm using a framwork which returns malformed Strings with "empty" characters from time to time.</p>
  
  <p>"foobar" for example is represented by:
  [,f,o,o,b,a,r]</p>
  
  <p>The first character is NOT a whitespace (' '), so a System.out.printlin() would return "foobar" and not " foobar". Yet, the length of the String is 7 instead of 6. Obviously this makes most String methods (equals, split, substring,..) useless. Is there a way to remove empty characters from a String?</p>
  
  <p>I tried to build a new String like this:</p>
  
  <pre><code>StringBuilder sb = new StringBuilder();
  for (final char character : malformedString.toCharArray()) {
    if (Character.isDefined(character)) {
      sb.append(character);
    }
  }
  sb.toString();
  </code></pre>
  
  <p>Unfortunately this doesn't work. Same with the following code:</p>
  
  <pre><code>StringBuilder sb = new StringBuilder();
  for (final Character character : malformedString.toCharArray()) {
    if (character != null) {
      sb.append(character);
    }
  }
  sb.toString();
  </code></pre>
  
  <p>I also can't check for an empty character like this:</p>
  
  <pre><code>   if (character == ''){
       //
     }
  </code></pre>
  
  <p>Obviously there is something wrong with the String .. but I can't change the framework I'm using or wait for them to fix it (if it is a bug within their framework). I need to handle this String and sanatize it.</p>
  
  <p>Any ideas?</p>