Java example: getting the substring after the first occurrence of a separator

ht‮t‬ps://www.lautturi.com
Java example: getting the substring after the first occurrence of a separator
/**
 * @author lautturi.com
 * Java example: get the substring after first given separator in java string
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {

		 String str = "Hello-Java-World";
	      String separator ="-";
	      int sepPos = str.indexOf(separator);
	      if (sepPos == -1) {
	         System.out.println("");
	      }
	      System.out.println("Substring after separator = "+str.substring(sepPos +       separator.length()));
		 
	}
}

output:

Substring after separator = Java-World
Created Time:2017-09-05 11:36:50  Author:lautturi