Here you can find the source of toArray(String array)
String should have the format "[a,b,c]"
.
Parameter | Description |
---|---|
array | the string to be parsed |
public static String[] toArray(String array)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww . ja va 2 s.c om * Cast a string to an array of objects * <p> * String should have the format <code>"[a,b,c]"</code>. * * @param array * the string to be parsed * @return the parsed array */ public static String[] toArray(String array) { // Empty array [] if (array.length() == 2) return new String[0]; return array.substring(1, array.length() - 1).split(","); } }