Name: rmT116609 Date: 09/18/2001 java version "1.3.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0) Java HotSpot(TM) Client VM (build 1.3.0, mixed mode) Whilst looking through the newsgroup articles at groups.google.com, I have seen several people stating that they would like to be able to get empty tokens back from StringTokenizer. There have also been people writing code to do this. Would it not be possible to do this in the core. SOURCE CODE BELOW: import java.io.*; import java.util.*; public class reporter { public reporter() { } public static void main(String args[]) { String line = "22||2|2|2"; StringTokenizer lineToken = new StringTokenizer(line, "|"); System.out.println(line); System.out.println("Tokens:"+lineToken.countTokens()); while (lineToken.hasMoreElements()) { System.out.println("T:"+lineToken.nextElement()); } } } (Review ID: 132119) ====================================================================== Classic VM (build JDK-1.2.2-004, green threads, sunwjit) I am trying to write a program that will reformat a pipe ("|") delimited file. The feature I would like to see added to the StringTokenizer is the ability for it to either return a null value or an empty string when two pipes appear together (i.e. ||). Currently it goes for the first string it finds regardless of what delimiters are before it. This is not what I want. (Review ID: 117513) ======================================================================
|