我有一套:
Set<String> tmpSet = FastSet.newInstance();
当我关注这个问题时:如何将 Set 转换为 String[]?
我也这样做:
String[] strArrStrings = includeFeatureIds.toArray(new String[0]);
我有这个例外:
Exception: java.lang.IllegalArgumentException
Message: Error running script at location [component://order/webapp/ordermgr/WEB-INF/actions/entry/catalog/KeywordSearch.groovy]: java.lang.UnsupportedOperationException: Destination array too small
---- cause ---------------------------------------------------------------------
Exception: java.lang.UnsupportedOperationException
Message: Destination array too small
---- stack trace ---------------------------------------------------------------
java.lang.UnsupportedOperationException: Destination array too small
javolution.util.FastCollection.toArray(FastCollection.java:351)
所以现在,我必须编码为:
for (FastSet.Record r = tmpSet.head(), end = tmpSet.tail(); (r = r.getNext()) != end;) {
// copy one by one element to String[]
}
我的问题:无论如何(或实用程序)将 FastSet 转换为 String[]?
感谢 :-)
也可以看看: