Here you can find the source of toArray(String text)
Parameter | Description |
---|---|
text | The text in format "[a,b,c]" |
public static String[] toArray(String text)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w ww. j a v a2s .com*/ * Convert the given text to String array. * * @param text * The text in format "[a,b,c]" * @return The String array * * @see #toString(Object[]) */ public static String[] toArray(String text) { if (text == null) return null; text = text.trim().replaceAll("\\[(.*)\\]", "$1").trim(); String regex = " *, *"; String[] array = text.split(regex); return array; } }