Here you can find the source of splitStruct(String struct)
public static Vector splitStruct(String struct)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static Vector splitStruct(String struct) { Vector vr = new Vector(); if (struct.startsWith("[") && struct.endsWith("]")) { struct = struct.substring(1, struct.length() - 1); } // end of if () StringTokenizer stok = new StringTokenizer(struct, " "); while (stok.hasMoreTokens()) { String tok = stok.nextToken(); if (tok.startsWith("[")) { StringBuffer sb = new StringBuffer(); while (!tok.endsWith("]")) { sb.append(tok);// w w w .j a va 2s .com sb.append(' '); tok = stok.nextToken(); } // end of while () sb.append(replace(tok, "]", ""));//add last element tok = sb.toString(); } // end of if () vr.addElement(tok); } // end of while () return vr; } public static String replace(String body, String findString, String replaceString) { return replace(body, findString, replaceString, false); } public static String replace(String body, String findString, String replaceString, boolean once) { //StringBuffer newBodyBuffer = new StringBuffer (findString.length()*2); StringBuffer newBodyBuffer = new StringBuffer(); char[] chars = body.toCharArray(); int start = 0; while (true) { int index = body.indexOf(findString, start); if (index == -1) break; newBodyBuffer.append(chars, start, index - start); newBodyBuffer.append(replaceString); start = index + findString.length(); if (once) break; } newBodyBuffer.append(chars, start, chars.length - start); return newBodyBuffer.toString(); } }