/**
* @author lautturi.com
* Java example: remove white space at the beginning of string in java
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
String str = " hello lautturi java world ";
System.out.println(str);
str = str.replaceAll("^\\s+","");
System.out.println(str);
}
}Source:www.lautturi.comoutput:
output: hello lautturi java world hello lautturi java world