Java Integer Array to String convertIntArrayToString(int[] data)

Here you can find the source of convertIntArrayToString(int[] data)

Description

Produces a String containing the given integers, separated by commas.

License

Open Source License

Parameter

Parameter Description
data An int array, eg: {-1, 7, 2}, {-1}, {}

Return

A String of comma-separated values, eg: "-1,7,2", "-1", ""

Declaration

public static String convertIntArrayToString(int[] data) 

Method Source Code

//package com.java2s;
/*/* ww w.  j  a v a  2s.  c  o  m*/
 * Copyright (c) 2009, SQL Power Group Inc.
 *
 * This file is part of SQL Power Library.
 *
 * SQL Power Library 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 3 of the License, or
 * (at your option) any later version.
 *
 * SQL Power Library 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.  If not, see <http://www.gnu.org/licenses/>. 
 */

public class Main {
    /**
     * Produces a String containing the given integers, separated by commas.
     * @param data An int array, eg: {-1, 7, 2}, {-1}, {}
     * @return A String of comma-separated values, eg: "-1,7,2", "-1", ""
     */
    public static String convertIntArrayToString(int[] data) {
        String s = "";
        for (int i = 0; i < data.length; i++) {
            s += String.valueOf(data[i]);
            if (i != data.length - 1) {
                s += ",";
            }
        }
        return s;
    }
}

Related

  1. arrayIntsToString(int... lst)
  2. arrayIntToString(int[] arrayInt)
  3. convertIntArrayToString(int[] data)
  4. convertIntArrayToString(int[] value, String separator)
  5. inputStreamToStr(InputStream is)
  6. inputStreamToStr(InputStream is)
  7. intArray2string(int intarr[])