Java String Chop Right chopRight(String str, char delimiter)

Here you can find the source of chopRight(String str, char delimiter)

Description

chop Right

License

Open Source License

Declaration

public static String chopRight(String str, char delimiter) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String chopRight(String str, char delimiter) {
        if (str == null || "".equals(str)) {
            return str;
        }//from   ww w  .j ava2s .  c  o  m
        int pos;
        for (pos = str.length() - 1; pos >= 0; pos--) {
            if (str.charAt(pos) != delimiter) {
                break;
            }
        }
        return str.substring(0, pos + 1);
    }
}

Related

  1. chopFromRight(String text, char character, int count)