Java String Implode implode(String[] array, String separator)

Here you can find the source of implode(String[] array, String separator)

Description

implode

License

Open Source License

Declaration

public static String implode(String[] array, String separator) 

Method Source Code

//package com.java2s;
/*//w  w w. j a  va  2  s.c  o m
 * BetterJobs - Jobs plugin for Bukkit 
 * Copyright (C) 2011 Abadon84 http://www.procrafter.de
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

public class Main {
    public static String implode(String[] array, String separator) {
        if (array.length == 0) {
            return "";
        }

        StringBuilder buffer = new StringBuilder();

        for (String str : array) {
            buffer.append(separator);
            buffer.append(str);
        }

        return buffer.substring(separator.length()).trim();
    }
}

Related

  1. implode(String[] args)
  2. implode(String[] arr_str, String pemisah)
  3. implode(String[] array, char delimiter)
  4. implode(String[] array, String glue)
  5. implode(String[] array, String separator)
  6. implode(String[] data, String delimiter)
  7. implode(String[] input)
  8. implode(String[] segments, String delimiter)
  9. implode(String[] strings, String delimiter)