Java String Tail tail(final String text, final char ch)

Here you can find the source of tail(final String text, final char ch)

Description

Return the string after the last occurance of the given character in the given string.

License

Open Source License

Parameter

Parameter Description
text a parameter
ch a parameter

Return

TODO Complete Documentation

Declaration

public static String tail(final String text, final char ch) 

Method Source Code

//package com.java2s;
/*//from w w  w  .j a v  a 2  s.com
 * Copyright (c) 2006 Stephan D. Cote' - All rights reserved.
 * 
 * This program and the accompanying materials are made available under the 
 * terms of the MIT License which accompanies this distribution, and is 
 * available at http://creativecommons.org/licenses/MIT/
 *
 * Contributors:
 *   Stephan D. Cote 
 *      - Initial concept and implementation
 */

public class Main {
    /**
     * Return the string after the last occurance of the given character in the
     * given string.
     *
     * <p>Useful for getting extensions from filenames. Also used to retrieve the
     * last segment of an IP address.</p>
     *
     * @param text
     * @param ch
     *
     * @return TODO Complete Documentation
     */
    public static String tail(final String text, final char ch) {
        final int indx = text.lastIndexOf(ch);
        return (indx != -1) ? text.substring(indx + 1) : text;
    }
}

Related

  1. tail(final String text, final char ch)
  2. tail(String s, char ch)
  3. tail(String s, String separator)
  4. tail(String src, String dividerRegex)
  5. tail(String text, String separator)