Java Array to String Array2String(String[] values)

Here you can find the source of Array2String(String[] values)

Description

Array String

License

LGPL

Declaration

public static String Array2String(String[] values) 

Method Source Code

//package com.java2s;
/**/*  w  w  w  .  ja  v  a 2 s  .  c  om*/
 * 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.*;

public class Main {
    public static String Array2String(String[] values) {
        String result = "";
        if (values == null) {
            return result;
        }
        int len = values.length;
        for (int i = 0; i < len; i++) {
            result += values[i] + ",";
        }
        if (result.endsWith(",")) {
            result = result.substring(result.length() - 1);
        }
        return result;
    }

    public static String Array2String(Object[] values) {
        String result = "";
        if (values == null) {
            return result;
        }
        int len = values.length;
        for (int i = 0; i < len; i++) {
            result += values[i].toString() + ",";
        }
        if (result.endsWith(",")) {
            result = result.substring(result.length() - 1);
        }
        return result;
    }

    public static String Array2String(List values) {
        String result = "";
        if (values == null) {
            return result;
        }
        int len = values.size();
        for (int i = 0; i < len; i++) {
            result += values.get(i).toString() + ",";
        }
        if (result.endsWith(",")) {
            result = result.substring(result.length() - 1);
        }
        return result;
    }
}

Related

  1. array2String(Object[] objs)
  2. array2String(String[] array)
  3. array2String(String[] array)
  4. array2String(String[] category)
  5. array2String(String[] p, String spliter)
  6. array2String(T... array)
  7. array2String(T[] array, String splitFlag, boolean useBracket)
  8. arrayContent(int[] ar)
  9. arrayToRLEString(int[] a)