How do I remove leading and trailing white space from string?

Bookmark this example!  
Category: java.lang, viewed: 833 time(s).
 
package org.kodejava.example.lang;
 
public class TrimStringExample {
    public static void main(String[] args) {
	String text = "     tattarrattat     ";
	
	//
	// The trim() method will result a new string object with a leading and
	// trailing while space removed.
	//
	System.out.println("Result: " + text.trim());
    }
}
 
 
Can't find what you are looking for? Join our FORUMS and ask some questions!
Firefox 2
Google

100 Top & Latest

GetJava Download Button

Locations of visitors to this page
eXTReMe Tracker
visitor stats