Java examples for java.lang:String Start
The following code shows how to Extract the first terms or word from the part of speech.
//package com.java2s; public class Main { public static void main(String[] argv) { String partOfSpeech = "java2s.com"; System.out.println(java.util.Arrays .toString(getSplitFirstAndRemaining(partOfSpeech))); }/* w w w . j a v a 2s .c om*/ /** * <p>Extract the first terms or word from the part of speech. The method generate an array * of two strings, first terms and remaining terms...</p> * @param partOfSpeech * @return */ public static String[] getSplitFirstAndRemaining(String partOfSpeech) { String[] splitTerms = null; partOfSpeech = partOfSpeech.trim(); int indexFirstSpace = partOfSpeech.indexOf(" "); /* * If the part of speech is not a single term.... then * break it down in first term and remaining terms... */ if (indexFirstSpace != -1) { splitTerms = new String[] { partOfSpeech.substring(0, indexFirstSpace).trim(), partOfSpeech.substring(indexFirstSpace).trim() }; } else { splitTerms = new String[] { partOfSpeech, null }; } return splitTerms; } }