Java Array to String arrayToString(String[] arr)

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

Description

Helper method serlializing an array as string using "/" as separator.

License

Open Source License

Parameter

Parameter Description
arr the array to serialize

Return

the string concatenation of the values in the array

Declaration

public static String arrayToString(String[] arr) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from www. j  a v a 2s.  c o m*/
     * Helper method serlializing an array as string using "/" as separator.
     * If the array is <code>null</code> or empty, the string <i>&lt;no values specified&gt;</i>
     * is returned.
     * @param arr the array to serialize
     * @return the string concatenation of the values in the array
     * @aribaapi private
     */
    public static String arrayToString(String[] arr) {
        if (arr != null && arr.length > 0) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < arr.length; i++) {
                builder.append(arr[i]);
                if (i < arr.length - 1) {
                    builder.append("/");
                }
            }
            return builder.toString();
        } else {
            return "<no values specified>";
        }
    }
}

Related

  1. arrayToString(String in[])
  2. arrayToString(String values[])
  3. arrayToString(String[] a, String delim)
  4. arrayToString(String[] a, String separator)
  5. arrayToString(String[] args, String delimiter)
  6. arrayToString(String[] arr, String expr)
  7. arrayToString(String[] array)
  8. arrayToString(String[] array)
  9. arrayToString(String[] array)