use StringTokenizer(String s, String delim)in this case, it would beStringTokenizer tok = new StringTokenizer(origString, "\n");