Java tutorial
//package com.java2s; import java.util.regex.Matcher; public class Main { /** * Invokes append tail on matcher with the given string buffer, and returns * the string buffer as a string. * * @param matcher the matcher. * @param sb the string buffer. * @return a string. */ public static String appendTail(Matcher matcher, StringBuffer sb) { matcher.appendTail(sb); return sb.toString(); } /** * Null-safe method for writing the items of a string array out as a string * separated by the given char separator. * * @param array the array. * @param separator the separator of the array items. * @return a string. */ public static String toString(String[] array, String separator) { StringBuilder builder = new StringBuilder(); if (array != null && array.length > 0) { for (String string : array) { builder.append(string).append(separator); } builder.deleteCharAt(builder.length() - 1); } return builder.toString(); } /** * Returns the string representation of the object, or null if the object is * null. * * @param object the object. * @return the string representation. */ public static String toString(Object object) { return object != null ? object.toString() : null; } }