String
value components.
*
* @author fredt@users
* @author boucherb@users
* @version 1.7.2
* @since 1.7.0
*/
public class StringUtil
{
///**
// * Builds a bracketed CSV list from the array
// * @param array an array of Objects
// * @return string
// */
//public static string arrayToString(Object array)
//{
// int len = ((Array)array).Length;
// int last = len - 1;
// StringBuilder sb = new StringBuilder(2 * (len + 1));
// sb.Append('{');
// for (int i = 0; i < len; i++)
// {
// sb.Append(((char[])array)[i]);
// if (i != last)
// {
// sb.Append(',');
// }
// }
// sb.Append('}');
// return sb.ToString();
//}
/**
* Builds a CSV list from the specified String[], separator string and
* quote string. * *
separator
argument.
* quote
argument.
* String
to use as the list element separator
* @param quote the String
with which to quote the list elements
* @param s array of String
objects
*/
public static string getList(String[] s, string separator, string quote)
{
int len = s.Length;
StringBuilder b = new StringBuilder(len * 16);
for (int i = 0; i < len; i++)
{
b.Append(quote);
b.Append(s[i]);
b.Append(quote);
if (i + 1 < len)
{
b.Append(separator);
}
}
return b.ToString();
}
}
}