hello i hope someone can help me please i have this code which i want to be able read in my txt file and read in the first line of the file and then check if it has a comma to seperate any words and to print the empty spaces aswell as the text but also i want to be able to print out any word of the file after i have iterated though it how can i do this thanks for your time jason
Vector v = new Vector(100); FileReader file = new FileReader("Work.txt"); BufferedReader buff = new BufferedReader(file); String line = buff.readLine(); StringTokenizer s = null; boolean eof = false; while (!eof){ s = new StringTokenizer(line.trim(),",",true); while (s.hasMoreTokens()) { cT = s.nextToken(); if (cT.equals(",") && lT.equals(",")){ v.add(""); } else{ if (!cT.equals(",")) { v.add(cT); } } lT = cT;
} line = buff.readLine(); if (line == null) eof = true;
} for (Enumeration e = v.elements();e.hasMoreElements();) { String se = (String)e.nextElement(); System.out.println(se);