get After Separator Or Nothing - Java java.lang

Java examples for java.lang:String Substring

Description

get After Separator Or Nothing

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String name = "java2s.com";
        System.out.println(getAfterSeparatorOrNothing(name));
    }/*ww  w  .j  a v a2  s . co  m*/

    private static final String SEPARATOR = ":";

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

Related Tutorials