Do you need to split a string into multiple values? Prior to Java 1.4, you would probably have used the StringTokenizer class to accomplish this.
In Java 1.4, Sun added a split() method to the String class. Using this method, you can very easily split a String into multiple values. The split() method takes a regular expression as a parameter which is used to split the String.
Below is an example of splitting a String:
//Data String
String data = "value 1,value 2,value 3";
//Split data into an array
String[] values = data.split(",");
4 comments:
Thanks. Helped me out a lot.
thanks, this is the method i looked for.
thanks a lot.. i was looking for this
thanks...
Post a Comment