Here you can find the source of tokenizeStringArray(String[] array, String token)
public static String tokenizeStringArray(String[] array, String token)
//package com.java2s; /*//from ww w. j a v a2 s.com * Copyright: (c) 2002-2006 Mayo Foundation for Medical Education and * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the * triple-shield Mayo logo are trademarks and service marks of MFMER. * * Except as contained in the copyright notice above, the trade names, * trademarks, service marks, or product names of the copyright holder shall * not be used in advertising, promotion or otherwise in connection with * this Software without prior written authorization of the copyright holder. * * Licensed under the Eclipse Public License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.eclipse.org/legal/epl-v10.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** this function returns a string that contains all the strings in the array delimited by the token. <br>Usage:<br> <pre> public static String[] myArray=new String[] {"Never","turn","your","back","on","your","terminology"}; String string = StringArrayUtility.tokenizeStringArray(myArray,", "); System.out.println("string="+string); output: string=Never, turn, your, back, on, your, terminology </pre> */ public static String tokenizeStringArray(String[] array, String token) { if (array.equals(null) || token.equals(null)) { return ""; } if (array.length > 0 && !array[0].equals(null)) { //System.out.println("array.length:"+array.length); //System.out.println("array[0]="+array[0]); StringBuffer string_buffer = new StringBuffer(array[0]); for (int i = 1; i < array.length; i++) {// System.out.println("array["+i+"]= "+array[i]); if (!array[i].equals(null) && !array[i].equals("")) { string_buffer.append(token); string_buffer.append(array[i]); } } //System.out.println("returning: "+string_buffer.toString()); return string_buffer.toString().trim(); } //System.out.println("returning nothing (at end)"); return ""; } }