Java Array Join join(Object[] strings, String spliter)

Here you can find the source of join(Object[] strings, String spliter)

Description

join

License

Apache License

Declaration

public static String join(Object[] strings, String spliter) 

Method Source Code

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

import java.util.List;

public class Main {
    public static String join(Object[] strings, String spliter) {
        int i = 0;
        StringBuffer buffer = new StringBuffer();
        for (Object s : strings) {
            if (i == 0) {
                buffer.append(s);/*from ww  w  .  j a v a 2 s . c o  m*/
                i = 1;
            } else {
                buffer.append(spliter + s);
            }
        }
        return buffer.toString();
    }

    public static String join(int[] strings, String spliter) {
        int i = 0;
        StringBuffer buffer = new StringBuffer();
        for (Object s : strings) {
            if (i == 0) {
                buffer.append(s);
                i = 1;
            } else {
                buffer.append(spliter + s);
            }
        }
        return buffer.toString();
    }

    public static String join(byte[] strings, String spliter) {
        int i = 0;
        StringBuffer buffer = new StringBuffer();
        for (Object s : strings) {
            if (i == 0) {
                buffer.append(s);
                i = 1;
            } else {
                buffer.append(spliter + s);
            }
        }
        return buffer.toString();
    }

    public static String join(List<String> strings, String spliter) {
        return join(strings.toArray(), spliter);
    }
}

Related

  1. join(Object[] elements, CharSequence separator)
  2. join(Object[] elements, String glue)
  3. join(Object[] objects)
  4. join(Object[] parts, String delim)
  5. join(Object[] strings, String delimiter)
  6. join(Object[] tokens, String delimiter)
  7. join(Object[] values, String join)
  8. join(Object[]... arrays)
  9. join(String delimiter, Object[] strings)