Java tutorial
//package com.java2s; import java.util.LinkedList; import java.util.List; public class Main { public static String[] extractTags(String source) { final List<String> result = new LinkedList<String>(); for (String tag : source.split(",")) { if (tag.trim().length() > 0) result.add(tag.trim()); } return result.toArray(new String[result.size()]); } }