@@ -0,0 +1,1311 @@
+package com.levelup.java.string;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.apache.commons.lang3.StringUtils;%0Aimport org.apache.log4j.Logger;%0Aimport org.junit.Test;%0A%0Aimport com.google.common.base.Splitter;%0A%0A/**%0A * This java example will demonstrate how to split a string by a comma.%0A * %0A * @author Justin Musgrove%0A * @see %3Ca href='http://www.leveluplunch.com//'%3E%3C/a%3E%0A */%0Apublic class SplitStringByComma %7B%0A%0A%09private static final Logger logger = Logger.getLogger(SplitStrings.class);%0A%0A%09@Test%0A%09public void split_string_comma_java() %7B%0A%0A%09%09String%5B%5D elementsInString = %22Yo,Gabba, Gabba, Keep Trying%22.split(%22,%22);%0A%0A%09%09logger.info(Arrays.toString(elementsInString));%0A%0A%09%09assertTrue(elementsInString.length == 4);%0A%09%7D%0A%0A%09@Test%0A%09public void split_string_comma_guava() %7B%0A%0A%09%09List%3CString%3E elementsInString = Splitter.on(%22,%22).splitToList(%0A%09%09%09%09%22Yo,Gabba, Gabba, Keep Trying%22);%0A%0A%09%09logger.info(elementsInString);%0A%0A%09%09assertEquals(4, elementsInString.size());%0A%0A%09%7D%0A%0A%09@Test%0A%09public void split_string_white_space_using_apache_commons() %7B%0A%0A%09%09String%5B%5D elementsInString = StringUtils.split(%0A%09%09%09%09%22Yo,Gabba, Gabba, Keep Trying%22, %22,%22);%0A%0A%09%09logger.info(Arrays.toString(elementsInString));%0A%0A%09%09assertTrue(elementsInString.length == 4);%0A%09%7D%0A%0A%7D%0A

Add split string by comma