Android String Trim rtrim(final String text)

Here you can find the source of rtrim(final String text)

Description

rtrim

License

Apache License

Declaration

public static final String rtrim(final String text) 

Method Source Code

//package com.java2s;
/*// w  w w.j av  a 2 s  .  c o m
 * Copyright 2004-2011 the Seasar Foundation and the Others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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. See the License for the specific language
 * governing permissions and limitations under the License.
 */

public class Main {

    public static final String rtrim(final String text) {
        return rtrim(text, null);
    }

    public static final String rtrim(final String text, String trimText) {
        if (text == null) {
            return null;
        }
        if (trimText == null) {
            trimText = " ";
        }
        int pos = text.length() - 1;
        for (; pos >= 0; pos--) {
            if (trimText.indexOf(text.charAt(pos)) < 0) {
                break;
            }
        }
        return text.substring(0, pos + 1);
    }
}

Related

  1. trimEnd(String s)
  2. nullsafeTrim(String str)
  3. trimScheme(String uri)
  4. ltrim(final String text)
  5. ltrim(final String text, String trimText)
  6. rtrim(final String text, String trimText)
  7. trimSuffix(final String text, final String suffix)
  8. trimPrefix(final String text, final String prefix)
  9. trimSpace(String oldString)