Dependent jar Package: Xwork-core-2.1.6.jar
Import java.util.ArrayList;
Import Java.util.HashSet;
Import java.util.List;
Import Java.util.Set;
Import Org.apache.commons.lang.xwork.StringUtils;
/**
* List, Set, array-round string
* @author RSun
* @Date 2012-11-01
*/
public class Test {
public static void Main (string[] args) {
String str = "";
List Spin string
list<string> list = new arraylist<string> ();
List.add ("A");
List.add ("B");
List.add ("C");
str = Stringutils.join (List.toarray (), ","); Returns a string based on different cutting characters
System.out.println ("Normal list conversion:" + str);
List.clear ();
str = Stringutils.join (List.toarray (), ",");
SYSTEM.OUT.PRINTLN ("size is 0 conversion:" + str);
String array to String
String[] Strarray = {"AA", "BB", "CC", "DD"};
str = Stringutils.join (Strarray, "-");
System.out.println ("Normal array conversion:" + str);
Strarray = new String[3];
str = Stringutils.join (Strarray, "-");
System.out.println ("Special array Conversion:" +STR);
Integer reference type spin string
integer[] array = new INTEGER[3];
Array[0] = 1;
ARRAY[2] = 2;
str = stringutils.join (Array, "-");
System.out.println ("Integer Conversion:" +STR);
Set converted to string
set<string> set = new hashset<string> ();
Set.add ("AA");
Set.add ("BB");
Set.add ("CC");
str = Stringutils.join (Set.toarray (), ";");
System.out.println ("Special array Conversion:" +STR);
}
}