Java String Trim Right rightTrimSlashes(String s)

Here you can find the source of rightTrimSlashes(String s)

Description

Returns the specified string with all trailing slashes removed.

License

Open Source License

Parameter

Parameter Description
s the input string

Return

the trimmed string

Declaration

public static String rightTrimSlashes(String s) 

Method Source Code

//package com.java2s;
/**/*  w  w  w.j ava2  s .  c om*/
 * Copyright (c) 2011 Martin Geisse
 *
 * This file is distributed under the terms of the MIT license.
 */

public class Main {
    /**
     * Returns the specified string with all trailing slashes removed.
     * @param s the input string
     * @return the trimmed string
     */
    public static String rightTrimSlashes(String s) {
        while (s.endsWith("/")) {
            s = s.substring(0, s.length() - 1);
        }
        return s;
    }
}

Related

  1. rightTrim(String value)
  2. rightTrim(String[] values)
  3. rightTrim(StringBuilder pStringBuilder)
  4. rightTrimNewLineChars(String input)
  5. rightTrimSize(String s)
  6. rightTrimString(String originalString)
  7. rtrim(final String input)
  8. rtrim(final String str)
  9. rtrim(final String str, final char filler)