Java String Trim Right rTrim(String str)

Here you can find the source of rTrim(String str)

Description

Remove trailing whitespace of the specified string using expressions.

License

Open Source License

Parameter

Parameter Description
str a parameter

Declaration

public static String rTrim(String str) 

Method Source Code

//package com.java2s;
/******************************************************************************
 * Copyright (C) Devamatre Technologies 2009
 * //  w w w.j a v a 2  s .  c om
 * This code is licensed to Devamatre under one or more contributor license 
 * agreements. The reproduction, transmission or use of this code or the 
 * snippet is not permitted without prior express written consent of Devamatre. 
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the license is distributed on an "AS IS" BASIS, WITHOUT 
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied and the 
 * offenders will be liable for any damages. All rights, including  but not
 * limited to rights created by patent grant or registration of a utility model 
 * or design, are reserved. Technical specifications and features are binding 
 * only insofar as they are specifically and expressly agreed upon in a written 
 * contract.
 * 
 * You may obtain a copy of the License for more details at:
 *      http://www.devamatre.com/licenses/license.txt.
 *      
 * Devamatre reserves the right to modify the technical specifications and or 
 * features without any prior notice.
 *****************************************************************************/

public class Main {
    /**
     * Remove trailing whitespace of the specified string using expressions.
     * 
     * @param str
     * @return
     */
    public static String rTrim(String str) {
        return str.replaceAll("\\s+$", "");
    }
}

Related

  1. rtrim(String str)
  2. rtrim(String str)
  3. rtrim(String str)
  4. rtrim(String str)
  5. rTrim(String str)
  6. rtrim(String str, String charList)
  7. rtrim(String str, String defaultValue)
  8. rtrim(String str, String suffixs)
  9. rtrim(String string, String end)