Class Iterators


  • @Deprecated(since="4.1.0",
                forRemoval=true)
    public class Iterators
    extends Object
    Deprecated, for removal: This API element is subject to removal in a future version.
    use Commons Collections or Guava instead.
    This class consists exclusively of static methods that operate on or return iterators. It is the Iterator-equivalent of Collections.
    • Constructor Summary

      Constructors 
      Constructor Description
      Iterators()
      Deprecated, for removal: This API element is subject to removal in a future version.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static <E,​C extends Collection<E>>
      C
      addAll​(Iterator<? extends E> iter, C collection)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adds all elements from the supplied iterator to the specified collection.
      static <E> List<E> asList​(Iterator<? extends E> iter)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get a List containing all elements obtained from the specified iterator.
      static void close​(Iterator<?> iter)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Closes the given iterator if it implements Closeable else do nothing.
      static void closeSilently​(Iterator<?> iter)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Closes the given iterator, swallowing any IOExceptions, if it implements Closeable else do nothing.
      static String toString​(Iterator<?> iter, String separator)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Converts an iterator to a string by concatenating all of the string representations of objects in the iterator, divided by a separator.
      static void toString​(Iterator<?> iter, String separator, StringBuilder sb)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Converts an iterator to a string by concatenating all of the string representations of objects in the iterator, divided by a separator.
    • Constructor Detail

      • Iterators

        public Iterators()
        Deprecated, for removal: This API element is subject to removal in a future version.
    • Method Detail

      • asList

        public static <E> List<E> asList​(Iterator<? extends E> iter)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Get a List containing all elements obtained from the specified iterator.
        Parameters:
        iter - the iterator to get the elements from
        Returns:
        a List containing all elements obtained from the specified iterator.
      • addAll

        public static <E,​C extends Collection<E>> C addAll​(Iterator<? extends E> iter,
                                                                 C collection)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Adds all elements from the supplied iterator to the specified collection.
        Parameters:
        iter - An iterator containing elements to add to the container.
        collection - The collection to add the elements to.
        Returns:
        The collection object that was supplied to this method.
      • toString

        public static String toString​(Iterator<?> iter,
                                      String separator)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Converts an iterator to a string by concatenating all of the string representations of objects in the iterator, divided by a separator.
        Parameters:
        iter - An iterator over arbitrary objects that are expected to implement Object.toString().
        separator - The separator to insert between the object strings.
        Returns:
        A String representation of the objects provided by the supplied iterator.
      • toString

        public static void toString​(Iterator<?> iter,
                                    String separator,
                                    StringBuilder sb)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Converts an iterator to a string by concatenating all of the string representations of objects in the iterator, divided by a separator.
        Parameters:
        iter - An iterator over arbitrary objects that are expected to implement Object.toString().
        separator - The separator to insert between the object strings.
        sb - A StringBuilder to append the iterator string to.
      • close

        public static void close​(Iterator<?> iter)
                          throws IOException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Closes the given iterator if it implements Closeable else do nothing.
        Parameters:
        iter - The iterator to close.
        Throws:
        IOException - If an underlying I/O error occurs.
      • closeSilently

        public static void closeSilently​(Iterator<?> iter)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Closes the given iterator, swallowing any IOExceptions, if it implements Closeable else do nothing.
        Parameters:
        iter - The iterator to close.