Java Array to String arrayToString(String[] array, String delim, boolean quotes)

Here you can find the source of arrayToString(String[] array, String delim, boolean quotes)

Description

array To String

License

Apache License

Declaration

public static String arrayToString(String[] array, String delim, boolean quotes) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String arrayToString(String[] array, String delim, boolean quotes) {
        StringBuilder result;//from   ww  w  .ja  v a  2  s  .c  o  m
        String quot = quotes ? "'" : "";

        if (array.length == 0)
            return "";

        result = new StringBuilder();

        for (String elem : array) {
            result.append(quot + elem + quot + delim);
        }
        result.deleteCharAt(result.length() - 1);

        return result.toString();
    }

    public static String arrayToString(String[] array) {
        return arrayToString(array, ",", true);
    }
}

Related

  1. arrayToString(String[] array)
  2. arrayToString(String[] array)
  3. arrayToString(String[] array)
  4. arrayToString(String[] array)
  5. arrayToString(String[] array, int start, String delimiter)
  6. arrayToString(String[] array, String separator)
  7. arrayToString(String[] array, String separator)
  8. arrayToString(String[] array, String separators)
  9. arrayToString(String[] arrayString, String splitStr)