Here you can find the source of arrayToInSQL(String column, List
public static String arrayToInSQL(String column, List<Object> list)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static String arrayToInSQL(String column, List<Object> list) { if (list.isEmpty()) return null; String appendString = ""; if (list.get(0) instanceof String) { appendString = "'"; }//w ww.j a v a 2s. c o m StringBuilder sb = new StringBuilder(column); sb.append(" in("); sb.append(appendString); sb.append(list.get(0)); sb.append(appendString); for (int i = 1; i < list.size(); i++) { sb.append(","); sb.append(appendString); sb.append(list.get(i)); sb.append(appendString); } sb.append(")"); return sb.toString(); } public static String arrayToInSQL(String column, Object[] list) { if (list == null || list.length == 0) return null; String appendString = ""; if (list[0] instanceof String) { appendString = "'"; } StringBuilder sb = new StringBuilder(column); sb.append(" in("); sb.append(appendString); sb.append(list[0]); sb.append(appendString); for (int i = 1; i < list.length; i++) { sb.append(","); sb.append(appendString); sb.append(list[i]); sb.append(appendString); } sb.append(")"); return sb.toString(); } }