Java tutorial
//package com.java2s; import java.util.Map; public class Main { public static void setOptionsPostStr(Map<String, String> ret, String optionName, boolean[] flags) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < flags.length; i++) { if (flags[i]) buf.append("," + i); } buf.deleteCharAt(0); ret.put(optionName, buf.toString()); } }