Here you can find the source of deleteWhitespace(String s)
Parameter | Description |
---|---|
s | a parameter |
public static String deleteWhitespace(String s)
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by public class Main { /**/* w ww. jav a2 s .co m*/ * @param s * @return a copy of the given string without any white space character. * @postcondition (s == null) --> result == null */ public static String deleteWhitespace(String s) { final String result; if (s == null) { result = null; } else { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { final char c = s.charAt(i); if (!Character.isWhitespace(c)) { sb.append(c); } } result = sb.toString(); } assert (s != null) || result == null; return result; } }