Java Utililty Methods Array to String

List of utility methods to do Array to String

Description

The list of methods to do Array to String are organized into topic(s).

Method

StringconvertArrayToString(String[] array, char seperator)
convert Array To String
if (array == null)
    return null;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.length; i++) {
    sb.append(array[i]);
    if (i != array.length - 1) {
        sb.append(seperator);
return sb.toString();
StringconvertArrayToString(String[] array, String separator)
* This method convert array to a string which is seperated by a seprator passed in argument.
StringBuilder builder = new StringBuilder();
for (String string : array) {
    if (string != null) {
        builder.append(separator).append(string);
return builder.substring(separator.length());
StringconvertArrayToString(String[] array, String separator)
Converts an Array of Strings into a formatted String
StringBuilder sb = new StringBuilder();
separator = (separator == null || separator.isEmpty()) ? " " : separator;
for (String str : array) {
    sb.append(str).append(separator);
return sb.toString().trim();
StringconvertArrayToString(String[] fields, String delimiter)
convert Array To String
StringBuilder csvStringBuilder = new StringBuilder();
for (int i = 0; i < fields.length; i++) {
    if (i > 0) {
        csvStringBuilder.append(delimiter);
    csvStringBuilder.append(fields[i]);
return csvStringBuilder.toString();
...
StringconvertArrayToString(String[] idArray)
convert Array To String
StringBuffer sb = new StringBuffer();
for (Object obj : idArray) {
    sb.append(obj);
    sb.append(",");
sb.delete(sb.length() - 1, sb.length());
return sb.toString();
StringconvertArrayToString(String[] strArray)
convert Array To String
StringBuffer strList = new StringBuffer();
if (strArray != null) {
    for (int i = 0; i < strArray.length; i++) {
        if (i != 0) {
            strList.append(",");
        strList.append(strArray[i]);
return strList.toString();
StringconvertByteToString(byte[] objectGuid)
convert Byte To String
StringBuilder builder = new StringBuilder();
for (byte element : objectGuid) {
    int item = element & 0xFF;
    if (item <= 0xF) {
        builder.append("0");
    builder.append(Integer.toHexString(item));
return builder.toString();
StringconvertToString(String[] args)
convert To String
List<String> stringList = new ArrayList<>();
for (int i = 0; i < args.length; i++)
    stringList.add(args[i]);
return convertToString(stringList);
StringconvertToString(String[] values, String separator)
Convert to string.
StringBuilder converted = new StringBuilder();
if (values != null) {
    for (String value : values) {
        if (converted.length() > 0) {
            converted.append(separator);
        converted.append(value);
return converted.toString();
StringdeepToString(Object[] a)
Returns a string representation of the "deep contents" of the specified array.
if (a == null)
    return "null";
int bufLen = 20 * a.length;
if (a.length != 0 && bufLen <= 0)
    bufLen = Integer.MAX_VALUE;
StringBuilder buf = new StringBuilder(bufLen);
deepToString(a, buf, new HashSet<Object[]>());
return buf.toString();
...