Here you can find the source of toJsonArrayString(Iterator
public static <T> JsonArray toJsonArrayString(Iterator<String> items)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonArrayBuilder; public class Main { public static <T> JsonArray toJsonArrayString(Iterator<String> items) { JsonArrayBuilder builder = Json.createArrayBuilder(); while (items.hasNext()) { builder.add(items.next());/*from ww w. j a v a 2 s . c om*/ } return builder.build(); } }