Java Array to String arrayToString(Object[] arr, String split)

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

Description

array To String

License

Apache License

Declaration

public static String arrayToString(Object[] arr, String split) 

Method Source Code

//package com.java2s;
/*//  w  w  w. j  av a  2s .  c om
 *
 *  Copyright 2018 FJN Corp.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *  Author                        Date                       Issue
 *  fs1194361820@163.com          2015-01-01                 Initial Version
 *
 */

public class Main {
    public static String arrayToString(Object[] arr, String split) {
        if (isEmpty(split)) {
            split = ", ";
        }
        StringBuilder buf = new StringBuilder();
        if (arr != null && arr.length > 0) {
            buf.append(arr[0]);
            for (int i = 1; i < arr.length; i++) {
                buf.append(split).append(arr[i]);
            }
        }
        return buf.toString();
    }

    public static boolean isEmpty(String str) {
        return str == null || str.isEmpty();
    }
}

Related

  1. arrayToString(Object[] args, String separator)
  2. arrayToString(Object[] arr)
  3. arrayToString(Object[] arr)
  4. arrayToString(Object[] arr)
  5. arrayToString(Object[] arr)
  6. arrayToString(Object[] array)
  7. arrayToString(Object[] array)
  8. arrayToString(Object[] array)
  9. arrayToString(Object[] array)