Here you can find the source of join(List
Parameter | Description |
---|---|
members | the strings to join |
quote | whether to quote each string |
private static String join(List<String> members, boolean quote)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**//from w w w . ja va2 s .c om * Helper to join a list of strings to a optionally quoted, comma separated string. * * @param members * the strings to join * @param quote * whether to quote each string * @return the single string containing a comma separated list of strings */ private static String join(List<String> members, boolean quote) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < members.size(); ++i) { if (i != 0) { builder.append(","); } if (quote) { builder.append('"').append(members.get(i)).append('"'); } else { builder.append(members.get(i)); } } return builder.toString(); } }