Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
269 views
in Programming by
recategorized by
Using above code I could retrive the String. Now I need to split it using space and then dot.
related to an answer for: read text file using Java

2 Answers

0 like 0 dislike
by The go-to Tester (181 points)
selected by
 
Best answer
You can use below code to split your String.

 

String[] splittedString = myString.split(","); // if (,) comma is your delimiter
0 like 0 dislike
by The go-to Tester (327 points)
reshown by
Try below line of code.

str = "1.Apple 2.Orange 3.Grape";
String[] splited = str.split("\\s+"); //This will cause any number of consecutive spaces to split your string into tokens.
for(int i=0;i<str.length;i++){
String[] newSplitted = splited[i].split(".");
System.out.println("Splited values:"+newSplitted[0] + " && " + newSplitted[1]);
}

Hope it helps


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...