Java Array to String convertToString(String[] args)

Here you can find the source of convertToString(String[] args)

Description

convert To String

License

Open Source License

Declaration

public static String convertToString(String[] args) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static String convertToString(String[] args) {
        List<String> stringList = new ArrayList<>();
        for (int i = 0; i < args.length; i++)
            stringList.add(args[i]);//from w  w w . j a va  2 s  .  c o m
        return convertToString(stringList);
    }

    private static String convertToString(List<String> strings) {
        StringBuilder builder = new StringBuilder();
        for (String s : strings)
            builder.append(s + " ");
        String out = removeLast(builder.toString());
        return out;
    }

    private static String removeLast(String str) {
        if (str.length() > 0) {
            str = str.substring(0, str.length() - 1);
        }
        return str;
    }
}

Related

  1. convertArrayToString(String[] array, String separator)
  2. convertArrayToString(String[] fields, String delimiter)
  3. convertArrayToString(String[] idArray)
  4. convertArrayToString(String[] strArray)
  5. convertByteToString(byte[] objectGuid)
  6. convertToString(String[] values, String separator)
  7. deepToString(Object[] a)
  8. encodedSeptetsToString(byte[] encodedSeptets)
  9. getArrayAsString(double[] vals)