Java examples for Language Basics:String
How to remove leading and trailing space from string
public class Main { public static void main(String[] args) { //from w ww .java 2 s . c om String str = " String Trim Example "; String strTrimmed = str.trim(); System.out.println("Original String is: " + str); System.out.println("Removed Leading and trailing space"); System.out.println("New String is: " + strTrimmed); } }