Java.util.StringTokenization

xiaoxiao2021-03-06  35

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)

转载请注明原文地址:https://www.9cbs.com/read-76079.html

New Post(0)