Java Array to String arrayToString(String[] stringArray)

Here you can find the source of arrayToString(String[] stringArray)

Description

array To String

License

Open Source License

Declaration

static String arrayToString(String[] stringArray) 

Method Source Code

//package com.java2s;
/* ====================================================================
 *
 * Copyright (C) 2007 - 2015 GeoSolutions S.A.S.
 * http://www.geo-solutions.it//from  w ww . j  a  v a  2  s .  c  o m
 *
 * GPLv3 + Classpath exception
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.
 *
 * ====================================================================
 *
 * This software consists of voluntary contributions made by developers
 * of GeoSolutions.  For more information on GeoSolutions, please see
 * <http://www.geo-solutions.it/>.
 *
 */

public class Main {
    static String arrayToString(String[] stringArray) {
        if (stringArray == null) {
            return "NULL";
        }
        if (stringArray.length == 0) {
            return "[]";
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append('[');
        for (String string : stringArray) {
            stringBuilder.append(string).append(", ");
        }
        stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length() - 1);
        stringBuilder.append(']');
        return stringBuilder.toString();
    }
}

Related

  1. arrayToString(String[] object)
  2. arrayToString(String[] s, String delim)
  3. arrayToString(String[] str, char sep)
  4. arrayToString(String[] str, String separator)
  5. arrayToString(String[] stringArray)
  6. arrayToString(String[] strings)
  7. arrayToString(String[] strs)
  8. arrayToString(String[] strs)
  9. arrayToString(String[] strs, String separator)