Java Collection to String collectionToString(Collection c, String spilt)

Here you can find the source of collectionToString(Collection c, String spilt)

Description

Formats a Date as a fifteen character long String made up of the Date's padded millisecond value.

License

LGPL

Return

a Date encoded as a String.

Declaration

public static final String collectionToString(Collection c, String spilt) 

Method Source Code

//package com.java2s;
/**// w w  w  . ja  v a  2 s  .c o  m
 * Converts a line of text into an array of lower case words using a
 * BreakIterator.wordInstance(). <p>
 *
 * This method is under the Jive Open Source Software License and was
 * written by Mark Imbriaco.
 *
 * @param text a String of text to convert into an array of words
 * @return text broken up into an array of words.
 */

import java.util.ArrayList;

import java.util.Collection;

public class Main {
    /**
     * Formats a Date as a fifteen character long String made up of the Date's
     * padded millisecond value.
     *
     * @return a Date encoded as a String.
     */
    public static final String collectionToString(Collection c, String spilt) {
        if (c == null) {
            return null;
        }
        if (spilt == null) {
            return null;
        }
        String ret = "";
        ArrayList a = new ArrayList(c);
        try {
            for (int i = 0; i < a.size(); i++) {
                String t = (String) a.get(i);
                if (i == a.size() - 1) {
                    ret = ret + t;
                } else {
                    ret = ret + t + spilt;
                }
            }
            return ret;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. collectionToStr(Collection collection)
  2. collectionToString( Collection collection)
  3. collectionToString(@SuppressWarnings("rawtypes") Collection coll)
  4. collectionToString(Collection c)
  5. collectionToString(Collection c, String delim)
  6. collectionToString(Collection col)
  7. collectionToString(Collection coll)
  8. collectionToString(Collection collection, String delim)
  9. collectionToString(Collection list, String split)