Amazing technological breakthrough possible @S-Logix

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • +91- 81240 01111

Social List

How to split the string in java?


StringTokenizer object available in util package is used to split the String. It splits the string into tokens using spaces between them. A file is chosen using JFileChooser and is read as string readLine method of BufferedReader object. Result is displayed in JTextArea. String class has the split method that splits the string based on the regular expression mentioned in the argument and stored in array. Here string is split using #.

Sample Code
  • Filename:SplitTest .java

class SplitTest {
public static void main(String args[]) throws IOException {
int m;
String sr = "Good#Learning#Environment";
String [] temp;
temp = sr.split("#");
for(m=0;m<temp.length;m++) {


Split the string in java