Java String Array to String arr2str(String[] arr)

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

Description

arrstr

License

Open Source License

Declaration

public static String arr2str(String[] arr) throws Exception 

Method Source Code

//package com.java2s;
/**/*from   w ww. j  a  v a 2  s .c om*/
 * Copyright 2014, 2015, 2016 TAIN, Inc. all rights reserved.
 *
 * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007 (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.gnu.org/licenses/
 *
 * 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.
 *
 * -----------------------------------------------------------------
 * Copyright 2014, 2015, 2016 TAIN, Inc.
 *
 */

public class Main {
    public static String arr2str(String[] arr) throws Exception {

        if (arr == null) {
            return "";
        }

        StringBuffer sb = new StringBuffer();

        for (int i = 0; i < arr.length; i++) {
            if (i > 0)
                sb.append("|");
            sb.append(arr[i]);
        }

        return sb.toString();
    }
}

Related

  1. argsToString(String args[], int minindex, int maxindex)
  2. argsToString(String separator, T... args)
  3. argsToString(String[] args)
  4. argsToString(String[] args, int start)
  5. argsToString(String[] args, int startFrom)
  6. arr2str(String[] arr, String sep)
  7. array2str(String[] array, String delim)
  8. array2str(String[] arrayname, int length)
  9. array2string(String array[])