Java Code Examples for java.util.AbstractCollection#iterator()
The following examples show how to use
java.util.AbstractCollection#iterator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollectionUtils.java From org.openntf.domino with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "cast" }) public static List<String> getListStrings(final AbstractCollection collection) { if ((null != collection) && (collection.size() > 0)) { final List<String> result = new ArrayList<String>(); if (collection.iterator().next() instanceof Object) { // treat as an object for (final Object o : collection) { if (null != o) { result.add(o.toString()); } } } else { // treat as a primitive final Iterator it = collection.iterator(); while (it.hasNext()) { result.add(String.valueOf(it.next())); } } return result; } return null; }
Example 2
Source File: Client.java From JFX-Browser with MIT License | 5 votes |
private static String join(AbstractCollection<String> col, String delimiter) { if (col.isEmpty()) return ""; Iterator<String> iter = col.iterator(); StringBuffer buffer = new StringBuffer(iter.next()); while(iter.hasNext()) buffer.append(delimiter).append(iter.next()); return buffer.toString(); }
Example 3
Source File: StringUtils.java From spork with Apache License 2.0 | 5 votes |
public static String join(AbstractCollection<String> s, String delimiter) { if (s.isEmpty()) return ""; Iterator<String> iter = s.iterator(); StringBuffer buffer = new StringBuffer(iter.next()); while (iter.hasNext()) { buffer.append(delimiter); buffer.append(iter.next()); } return buffer.toString(); }
Example 4
Source File: LoadFunc.java From spork with Apache License 2.0 | 5 votes |
/** * Join multiple strings into a string delimited by the given delimiter. * * @param s a collection of strings * @param delimiter the delimiter * @return a 'delimiter' separated string */ public static String join(AbstractCollection<String> s, String delimiter) { if (s.isEmpty()) return ""; Iterator<String> iter = s.iterator(); StringBuffer buffer = new StringBuffer(iter.next()); while (iter.hasNext()) { buffer.append(delimiter); buffer.append(iter.next()); } return buffer.toString(); }
Example 5
Source File: StringManipulationHelper.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
public static String join(AbstractCollection<String> s, String delimiter) { if (s == null || s.isEmpty()) return ""; Iterator<String> iter = s.iterator(); StringBuilder builder = new StringBuilder(iter.next()); while( iter.hasNext() ) { builder.append(delimiter).append(iter.next()); } return builder.toString(); }