print Map to a String via StringBuilder - Java java.util

Java examples for java.util:Map Operation

Description

print Map to a String via StringBuilder

Demo Code


//package com.java2s;
import java.util.Arrays;
import java.util.Map;

public class Main {
    public static String printStrsMap(Map<String, String[]> map) {
        StringBuilder stringBuilder = new StringBuilder();

        for (Map.Entry<String, String[]> entry : map.entrySet()) {
            stringBuilder.append(entry.getKey()).append("=")
                    .append(Arrays.toString(entry.getValue()))
                    .append("\r\n");
        }//from   ww  w . j a va 2s . c om

        return stringBuilder.toString();
    }
}

Related Tutorials