/**
* @author lautturi.com
* Java example: Java remove white spaces from string
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
String str = " hello lautturi world \r\n" +
" java world";
System.out.println(str);
str = str.replaceAll("\\s+","");
System.out.println(str);
}
}Source:www.lautturi.comoutput:
hello lautturi world java world hellolautturiworldjavaworld