java remove white space at the end of string

java remove white space at the end of string
/**
 * @author lautturi.com 
 * Java example: remove white space at the end 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:‮w‬ww.lautturi.com

output:

output:

   hello lautturi java world   
   hello lautturi java world
Created Time:2017-09-28 17:18:08  Author:lautturi