Write code to split a string and return a Vector
//package com.book2s; import java.util.Vector; public class Main { public static void main(String[] argv) { String str = "book2s.com"; char delim = '.'; System.out.println(split(str, delim)); }/*from w ww.jav a 2s. co m*/ public static Vector split(String str, char delim) { Vector tokens = new Vector(); String token = ""; for (int i = 0; i < str.length(); i++) { if (str.charAt(i) == delim) { tokens.addElement(token); token = ""; } else { token += str.charAt(i); } } if (token.length() > 0) { tokens.addElement(token); } return tokens; } }