title: How to remove whitespace in String imported from Excel
body: <p>I need to remove all white character from a string and I am not able to do so.
  Anyone has an idea on how to do it?</p>
  
  <p>Here is my string retrieved from an excel file via jxl API : </p>
  
  <pre><code>"Destination à gauche"
  </code></pre>
  
  <p>And here are its bytes :</p>
  
  <pre><code>6810111511610511097116105111110-96-32321039711799104101
  </code></pre>
  
  <p>There is the code I use to remove whitespaces :</p>
  
  <pre><code>public static void checkEntetes(Workbook book) {
          String sheetName = "mysheet";
          System.out.print(sheetName + " : ");
          for(int i = 0; i &lt; getColumnMax(book.getSheet(sheetName)); i++) {
              String elementTrouve = book.getSheet(sheetName).getCell(i, 0).getContents();
              String fileEntete = new String(elementTrouve.getBytes()).replaceAll("\\s+","");
              System.out.println("\t" + elementTrouve + ", " + bytesArrayToString(elementTrouve.getBytes()));
              System.out.println("\t" + fileEntete + ", " + bytesArrayToString(fileEntete.getBytes()));
          }
          System.out.println();
  }
  </code></pre>
  
  <p>And this outputs : </p>
  
  <pre><code>"Destination à gauche", 6810111511610511097116105111110-96-32321039711799104101
  "Destination àgauche", 6810111511610511097116105111110-96-321039711799104101
  </code></pre>
  
  <p>I even tried to make it myself and it still leaves a space before the 'à' char.</p>
  
  <pre><code>public static String removeWhiteChars(String s) {
      String retour = "";
      for(int i = 0; i &lt; s.length(); i++) {
          char c = s.charAt(i);
          if(c != (char) ' ') {
              retour += c;
          }
      }
      return retour;
  }
  </code></pre>