Java Array to String toString(Map arg)

Here you can find the source of toString(Map arg)

Description

to String

License

Apache License

Declaration

public static String toString(Map<String, String[]> arg) 

Method Source Code


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

import java.util.Arrays;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class Main {
    public static String toString(Map<String, String[]> arg) {
        String str = null;/*from w  ww .j a va 2 s .  c o m*/

        if (arg != null) {
            StringBuffer sb = new StringBuffer();
            sb.append("{");

            Set<Entry<String, String[]>> entries = arg.entrySet();
            for (Entry<String, String[]> entry : entries) {
                String key = entry.getKey();
                String val = Arrays.toString(entry.getValue());
                sb.append(key + "=" + val + ", ");
            }

            int len = sb.length();
            if (sb.charAt(len - 1) == ' ') {
                sb.delete(len - 2, len);
            }

            sb.append("}");
            str = sb.toString();
        }

        return str;
    }

    public static String toString(Object[] objects) {
        if (objects == null) {
            return null;
        }
        return Arrays.toString(objects);
    }

    public static String toString(Object object) {
        if (object == null) {
            return null;
        }
        return object.toString();
    }
}

Related

  1. toString(int X[][])
  2. toString(int[] a, int maxValues)
  3. toString(int[] codes)
  4. toString(int[] v, char delim)
  5. toString(long[] dom)
  6. toString(Object array)
  7. toString(Object array)
  8. toString(Object array)
  9. toString(Object array[])