Java Array Flatten flattenArray(String[] aString)

Here you can find the source of flattenArray(String[] aString)

Description

Flattens a string array for printing with NO commas

License

Open Source License

Parameter

Parameter Description
aString the string array to flatten

Return

the string for printing.

Declaration

public static String flattenArray(String[] aString) 

Method Source Code

//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();
    }
}

Related

  1. flatten(String s[])
  2. flatten(String[] strings, String separator)
  3. flattenArguments(String[] arguments)
  4. flattenArray(Object... objects)
  5. flattenArray(Object[] words)
  6. flattenBytes(byte[] b)
  7. flattenIndices(int[] indices, int[] extents)
  8. flattenNTriples(final String[] values)
  9. flattenStringArray(String[] s_array, String delimiter)