Java String Trim Right rTrim(String orgStr, String delimiter)

Here you can find the source of rTrim(String orgStr, String delimiter)

Description

Right Trim the empty space before the delimiter presents in the string

License

Open Source License

Parameter

Parameter Description
String delimiter

Return

String trimStr

Declaration

public static String rTrim(String orgStr, String delimiter) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w.ja va2  s.c om*/
 * @(#)MessageUtil.java
 *
 * Copyright by ObjectFrontier, Inc.,
 * 2050 Marconi Drive, Alpharetta, GA 30005, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of ObjectFrontier, Inc. You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of
 * the license agreement you entered into with ObjectFrontier.
 */

public class Main {
    /**
     * Right Trim the empty space before the delimiter presents in the string
     * 
     * @param String orgStr
     * @param String delimiter
     * 
     * @return String trimStr 
     *   
     */
    public static String rTrim(String orgStr, String delimiter) {

        try {

            int index = orgStr.indexOf(delimiter);
            orgStr = ((orgStr.substring(0, index)).trim().length() > 0) ? orgStr : orgStr.substring(index);

            return orgStr;
        } catch (Throwable th) {

            // ignore exception
            return orgStr;
        }
    }
}

Related

  1. rtrim(final String str)
  2. rtrim(final String str, final char filler)
  3. rtrim(final String text)
  4. rTrim(final String value)
  5. rtrim(String input)
  6. rtrim(String orig)
  7. rtrim(String pString)
  8. rtrim(String s)
  9. rTrim(String s)