String Tokenizer
The content of the following script is very similar to some other scripts in the repository. The tokenizer takes a string and breaks it into smaller strings at every space. So if I had a sentence like: "the answer is 42" the tokenizer would give me an array of strings like this:
the
answer
is
42
Broken on every space.
in this example a state is seperated by a zip with only a space between them.
stateZip = (String)dataRecord.get("STATE_ZIP");
tokenizer = new StringTokenizer(stateZip);
//the first token goes into the state
state = tokenizer.nextToken();
//the second token is the Zip
zip = tokenizer.nextToken();
//now put them into their dataRecord Variables
dataRecord.put("STATE",state);
dataRecord.put("ZIP",zip);
//print out to the log so you can see the values.
session.log("STATE=" + dataRecord.get("STATE"));
session.log("ZIP=" + dataRecord.get("ZIP"));