/** * Split a string based on the presence of a specified separator. Returns an array of arbitrary * length. The end of each element in the array is indicated by the separator of the end of the * string. If there is a separator immediately before the end of the string, the final element * will be empty. None of the strings will contain the separator. Useful when separating strings * such as "foo/bar/bas" using separator "/". * * @param sep The separator. * @param s The string to split. * @return An array of strings. Each string in the array is determined by the location of the * provided sep in the original string, s. Whitespace not stripped. */ private String[] splitSeparator(String sep, String s) { Vector v = new Vector(); int tokenStart = 0; int tokenEnd = 0; while ((tokenEnd = s.indexOf(sep, tokenStart)) != -1) { v.addElement(s.substring(tokenStart, tokenEnd)); tokenStart = tokenEnd + 1; } // Add the final element. v.addElement(s.substring(tokenStart)); String[] retVal = new String[v.size()]; v.copyInto(retVal); return retVal; }
/** How many applets are running? */ public static int countApplets() { return appletPanels.size(); }