Android String Strip stripEnd(String str, String stripChars)

Here you can find the source of stripEnd(String str, String stripChars)

Description

strip End

Declaration

public static String stripEnd(String str, String stripChars) 

Method Source Code

//package com.java2s;

public class Main {
    public static String stripEnd(String str, String stripChars) {
        int end;//  w  w w  .  j  a v  a2s .  c o m
        if (str == null || (end = str.length()) == 0) {
            return str;
        }

        if (stripChars == null) {
            while ((end != 0)
                    && Character.isWhitespace(str.charAt(end - 1))) {
                end--;
            }
        } else if (stripChars.length() == 0) {
            return str;
        } else {
            while ((end != 0)
                    && (stripChars.indexOf(str.charAt(end - 1)) != -1)) {
                end--;
            }
        }
        return str.substring(0, end);
    }
}

Related

  1. stripCharacter(String inputString, char stripCharacter)
  2. stripCharacters(String inputString, String stripCharacters)
  3. stripControlCharacters(Object value)
  4. stripControlCharacters(String value)
  5. stripEnd(String str, String stripChars)
  6. stripStart(String str, String stripChars)
  7. stripStart(String str, String stripChars)