Here you can find the source of convertIntArrayToString(int[] data)
Parameter | Description |
---|---|
data | An int array, eg: {-1, 7, 2}, {-1}, {} |
public static String convertIntArrayToString(int[] data)
//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; } }