Today, I have a big job of the database today, in which one function is to enter a "," separated digital string, fill the resulting number into an array, he wrote one, very awkward
. I propose him to use the Java.util.StringTokenization class. That class is very convenient:
StringTokenizer ST = New StringTokenizer ("this is a test", ""
While (st.hasmoretokens ()) {
System.out.println (st.nextToken ());
}
Output:
THIS
IS
a
Test
(The second string in the constructor is the collection of separators, the default is spaced)