Java Iterator concatinateElements(Iterator it)

Here you can find the source of concatinateElements(Iterator it)

Description

concatinate Elements

License

Open Source License

Declaration

private static String concatinateElements(Iterator<?> it) 

Method Source Code

//package com.java2s;
/*****************************************************************************
 * This file is part of the Prolog Development Tool (PDT)
 * /*from  w ww .j  a v  a 2 s.c  om*/
 * Author: Lukas Degener (among others)
 * WWW: http://sewiki.iai.uni-bonn.de/research/pdt/start
 * Mail: pdt@lists.iai.uni-bonn.de
 * Copyright (C): 2004-2012, CS Dept. III, University of Bonn
 * 
 * All rights reserved. This program is  made available under the terms
 * of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 * 
 ****************************************************************************/

import java.util.Iterator;

public class Main {
    private static String concatinateElements(Iterator<?> it) {
        StringBuffer sb = new StringBuffer();
        boolean first = true;
        while (it.hasNext()) {
            if (!first) {
                sb.append(", ");
            }
            Object next = it.next();
            String elm = next == null ? "<null>" : next.toString();
            sb.append(elm);
            first = false;
        }
        return sb.toString();
    }
}

Related

  1. asList(Iterator it)
  2. asStringOn(StringBuffer sb, Iterator iter, String separator)
  3. cast(Iterator p)
  4. closeIterator(Iterator iterator)
  5. compareRanges(final Iterator i, final Iterator j)
  6. concatIterators(final Iterator... iterators)
  7. concatLines(Iterator lineIterator)
  8. contains(final Iterator iter, final E item)
  9. contains(Iterator it, T o)