get After Separator Or All - Java java.lang

Java examples for java.lang:String Substring

Description

get After Separator Or All

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String name = "java2s.com";
        System.out.println(getAfterSeparatorOrAll(name));
    }/*from www .  ja v a 2  s . c  om*/

    private static final String SEPARATOR = ":";

    public static String getAfterSeparatorOrAll(String name) {
        int index = name.indexOf(SEPARATOR);
        if (index == -1)
            return name;
        else
            return name.substring(index + 1);
    }
}

Related Tutorials