public static String encodeArray(String[] array){
  StringBuilder buffer=new StringBuilder();
  int nrItems=array.length;
  for (int i=0; i < nrItems; i++) {
    String item=array[i];
    item=StringUtil.gsub("_","__",item);
    buffer.append(item);
    if (i < nrItems - 1) {
      buffer.append("_.");
    }
  }
  return buffer.toString();
}

public static String encodeArray ( String [ ] array ) { StringBuilder buffer = new StringBuilder ( ) ; int nrItems = array . length ; for ( int i = 0 ; i < nrItems ; i ++ ) { String item = array [ i ] ; item = StringUtil . gsub ( "_" , "__" , item ) ; buffer . append ( item ) ; if ( i < nrItems - 1 ) { buffer . append ( "_." ) ; } } return buffer . toString ( ) ; }
encodes an array of strings into a single string than can be decoded to the original array using the corresponding decode method . useful for e . g . storing an array of strings as a single entry in a preferences node .
