| 1 21 package proguard.util; 22 23 import java.util.*; 24 25 26 32 public class ListUtil 33 { 34 37 public static String commaSeparatedString(List list) 38 { 39 if (list == null) 40 { 41 return null; 42 } 43 44 StringBuffer buffer = new StringBuffer (); 45 46 for (int index = 0; index < list.size(); index++) 47 { 48 if (index > 0) 49 { 50 buffer.append(','); 51 } 52 53 buffer.append(list.get(index)); 54 } 55 56 return buffer.toString(); 57 } 58 59 60 63 public static List commaSeparatedList(String string) 64 { 65 if (string == null) 66 { 67 return null; 68 } 69 70 List list = new ArrayList(); 71 int index = 0; 72 while (index < string.length()) 73 { 74 int nextIndex = string.indexOf(',', index); 75 if (nextIndex < 0) 76 { 77 nextIndex = string.length(); 78 } 79 80 list.add(string.substring(index, nextIndex).trim()); 81 82 index = nextIndex + 1; 83 } 84 85 return list; 86 } 87 } 88 | Popular Tags |