Java Array to String arrayToString(String[] input)

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

Description

Helper method used to convert an Array of Strings into one multiline String.

License

Open Source License

Parameter

Parameter Description
input The Array of Strings to be converted.

Return

The converted String.

Declaration

public static String arrayToString(String[] input) 

Method Source Code

//package com.java2s;
/*// ww  w.ja v a2s . c o  m
 * Filename: CLIHelper.java
 * 
 * Copyright 2015 Jean-Pierre Hoehmann (jeanpierre.hoehmann@gmail.com)
 *
 * This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hovecar. See 
 * http://www.wtfpl.net/ for more details.
 */

public class Main {
    /**
     * Helper method used to convert an Array of Strings into one multiline String.
     *
     * @param input
     *            The Array of Strings to be converted.
     * @return The converted String.
     */
    public static String arrayToString(String[] input) {

        String output = "";

        // Iterate over the array and append each line including a line feed to the output.
        // This will produce a String with a trailing newline.
        // Restoration of the original String is not possible,
        // because stringToArray simply strips trailing newlines for easier formatting.
        for (int i = 0; i < input.length; i++) {
            output += input[i];
            output += System.lineSeparator();
        }

        return output;
    }
}

Related

  1. arrayToString(String[] array, String delim, boolean quotes)
  2. arrayToString(String[] array, String separator)
  3. arrayToString(String[] array, String separator)
  4. arrayToString(String[] array, String separators)
  5. arrayToString(String[] arrayString, String splitStr)
  6. arrayToString(String[] lengthsAndDelimiters)
  7. arrayToString(String[] lines, String separator)
  8. arrayToString(String[] ngram)
  9. arrayToString(String[] object)