Java tutorial
//package com.java2s; public class Main { private static String toStringByArray(Object[] value) { StringBuffer sb = new StringBuffer(100); String type = value[0].getClass().getName(); sb.append("{").append(type).append("@"); for (int i = 0; i < value.length; i++) { sb.append(esc(value[i].toString())).append(","); } return sb.substring(0, sb.length() - 1) + "}"; } private static String esc(String str) { return str.replaceAll(":", "&&&").replaceAll("\\[", "&!&").replaceAll("\\]", "!&!").replaceAll(",", "!!!") .replaceAll("\\{", "!!&").replaceAll("\\}", "&&!").replaceAll("@", "###"); } }