Java examples for java.lang:String Split
The following code shows how to get First Split.
//package com.java2s; public class Main { public static void main(String[] argv) { String content = "java2s.com"; String delim = "."; System.out.println(getFirstSplit(content, delim)); }/* ww w .j av a 2 s .c om*/ public static String getFirstSplit(final String content, final String delim) { String firstClass = null; if (content != null && delim != null) { int indexFirstDelim = content.indexOf(delim); firstClass = (indexFirstDelim == -1) ? content : content .substring(0, indexFirstDelim); } return firstClass; } }