Here you can find the source of formatBytableCols(Object[] obj, String[] tableCols)
public static String formatBytableCols(Object[] obj, String[] tableCols)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static String formatBytableCols(Object[] obj, String[] tableCols) { StringBuffer result = new StringBuffer(); result.append("{"); if (obj != null && obj.length > 0) { for (int i = 0; i < obj.length; i++) { try { result.append(tableCols[i]); result.append(":'"); if (obj[i] instanceof String) { String s = null; if (obj[i].toString() != null) { s = obj[i].toString().replace("\"", "\\\"").replace("'", "\\'").replace("\n", "<br/>") .replace("\b", "\\b").replace("\f", "\\f").replace("\r", "").replace("\t", ""); }//from w ww .ja v a 2 s . com result.append(s); } else if (obj[i] instanceof Integer) { result.append((Integer) obj[i]); } else if (obj[i] instanceof Long) { result.append((Long) obj[i]); } else if (obj[i] instanceof Double) { result.append((Double) obj[i]); } else if (obj[i] instanceof java.sql.Date) { result.append((java.sql.Date) obj[i]); } else if (obj[i] instanceof Float) { result.append((Float) obj[i]); } result.append("'"); if (i < obj.length - 1) { result.append(","); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } } } result.append("}"); System.out.println(result.toString()); return result.toString(); } public static String formatBytableCols(List<Object[]> list, String[] tableCols) { StringBuffer result = new StringBuffer(); result.append("["); if (!list.isEmpty()) { for (int i = 0; i < list.size(); i++) { Object[] obj = (Object[]) list.get(i); result.append(formatBytableCols(obj, tableCols)); if (i < list.size() - 1) result.append(","); } } result.append("]"); return result.toString(); } }