Here you can find the source of flattenArray(String[] aString)
Parameter | Description |
---|---|
aString | the string array to flatten |
public static String flattenArray(String[] aString)
//package com.java2s; /**// w w w. j av a 2s.com * Copyright (C) 2014 MudRaker * 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 3 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. */ public class Main { /** * Flattens a string array for printing with NO commas * @param aString the string array to flatten * @return the string for printing. */ public static String flattenArray(String[] aString) { StringBuilder sb = new StringBuilder(); for (String s : aString) { if (sb.length() > 0) sb.append(" "); sb.append(s.toString()); } return sb.toString(); } }