1 5 package com.opensymphony.oscache.util; 6 7 import java.util.ArrayList ; 8 import java.util.List ; 9 10 15 public class StringUtil { 16 17 26 public static final List split(String str, char delimiter) { 27 if ((str == null) || "".equals(str)) { 29 return new ArrayList (); 30 } 31 32 ArrayList parts = new ArrayList (); 33 int currentIndex; 34 int previousIndex = 0; 35 36 while ((currentIndex = str.indexOf(delimiter, previousIndex)) > 0) { 37 String part = str.substring(previousIndex, currentIndex).trim(); 38 parts.add(part); 39 previousIndex = currentIndex + 1; 40 } 41 42 parts.add(str.substring(previousIndex, str.length()).trim()); 43 44 return parts; 45 } 46 47 51 public static final boolean hasLength(String s) { 52 return (s != null) && (s.length() > 0); 53 } 54 55 } 56 | Popular Tags |