/** * @author lautturi.com * Java example: java remove all whitespace from string */ import java.util.*; public class Lautturi { public static void main(String[] args) { String str = "hello lautturi java world! "; str = str.replaceAll("\\s+",""); System.out.println(str); } }
output:
hellolautturijavaworld!