* Implement StringUtlils.collect() that converts an Enumeration to a String array.
This commit is contained in:
parent
882dfacb2e
commit
acb9676f0c
1 changed files with 16 additions and 0 deletions
|
@ -18,6 +18,9 @@ package helma.util;
|
||||||
|
|
||||||
|
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for String manipulation.
|
* Utility class for String manipulation.
|
||||||
|
@ -68,4 +71,17 @@ public class StringUtils {
|
||||||
return str == null ? new char[0] : str.toCharArray();
|
return str == null ? new char[0] : str.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect items of a string enumeration into a String array.
|
||||||
|
* @param enum an enumeration of strings
|
||||||
|
* @return the enumeration values as string array
|
||||||
|
*/
|
||||||
|
public static String[] collect(Enumeration enum) {
|
||||||
|
List list = new ArrayList();
|
||||||
|
while (enum.hasMoreElements()) {
|
||||||
|
list.add(enum.nextElement());
|
||||||
|
}
|
||||||
|
return (String[]) list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue