How to split a String into an Array in a JavaAgent

How can I split a string into an Array in a JavaAgent. I have a string like “NAME;PHONE;STREET” and I want to split it into an Array in a javaAgent.

Does anyone know an easy way to do that?

Thanks

Fabio

Subject: How to split a String into an Array in a JavaAgent

Oh, come on. This isn’t even a Notes/Domino question, it’s extremely basic Java, and there are resources all over the place that you could/should have consulted before you posted this question here. You’re using JDK 1.3.1, right? Try using StringTokenizer to “chunk” the data. If you really, really need an array, you can build one by iterating over the tokenizer object:

while (tokenizer.hasMoreTokens()) {…}

You can dimension your array using countTokens().

Subject: RE: How to split a String into an Array in a JavaAgent

Yeah this is really basic, but Im wondering if someone has the split method done already, I wont waste my time bulding something that should be on the String class in java 1.3.

Sorry to bother you with my question!

Subject: RE: How to split a String into an Array in a JavaAgent

split() was added in JDK 1.4 (it uses Regular Expressions rather than a character to split on). We’re only talking about, what, a five-line method? Try using Google – search for “Java split() tokenizer” (without the quotes); the first entry you get back will have your routine.

Subject: RE: How to split a String into an Array in a JavaAgent

it is a five-line method for those who know Java. I can do that in formula or LotusScript in one-line method, but Im not a Java developer, Im trying to help a friend. I saw that the split method only exists in release 1.4. The java documentation is really hard to find something when you dont know much about Java. How would I guess that a class Im looking for is called “tokenizer”??!?!!? The documentation should put some links in to the String class for related topics such as this StringTokenizer".

I’ve created a method with the StringTokenizer already. Just keep in mind that what is basic for you, may not be for others that does not have all Java Classes in their mind.

Thanks for the help anyway!

Subject: RE: How to split a String into an Array in a JavaAgent

By “basic” I don’t mean “easy” – I mean that it’s not Domino-specific, so your best resources aren’t these fora. Please don’t take this as a denegration of your skill, but rather as a pointer to better places to look for help. This is obviously the place to come to when you’re having trouble wrestling with sessions and views and NotesThreads and getItemValueString(), but probably the WORST place to come for help with the core (the basics) of Java. By far the majority of people working in Domino with Java are doing so either (a) as more-or-less newbies, trying to add to their skill sets, or (b) using Java occasionally to do something that Java does and LotusScript does not. A lot of them (us) are (or are nearly) Domino experts, but we don’t carry that same level of expertise with Java.

So, please, when I tell you that this is the wrong place for basic Java questions, I don’t mean to discourage you on your quest. I mean that this is the wrong place for basic Java questions. You’re at least as likely to get LotusScript “written in” Java as you are to get “real” Java – and that’s usually the wrong way to do things.