chat_bubble
Questions
highlight
Hot!
local_offer
Tags
note
Meetups
note
Tutorials
note
Jobs
note
Blogs
close
menu
Question view
power_settings_new
search
How do I separate string using space and dot
by
Prasanth
asked
Aug 20, 2015
0
votes
59
views
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
java
Please
log in
or
register
to add a comment.
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
2
Answers
answered
Aug 25, 2015
by
stbadmin
(
151
points)
selected
Mar 7, 2017
by
stbadmin
0
votes
Best answer
You can use below code to split your String.
String[] splittedString = myString.split(","); // if (,) comma is your delimiter
Please
log in
or
register
to add a comment.
answered
Aug 20, 2015
by
KeeshaGolden
(
327
points)
reshown
Aug 25, 2015
by
stbadmin
0
votes
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
Please
log in
or
register
to add a comment.
Related questions
chat_bubble
java split string using . dot does not work
1
keyboard_arrow_down
0
votes
asked
Dec 31, 2015
by
anonymous
java
chat_bubble
how do I clear all comoboxes at once in JFrame and add values to the same at once?
2
keyboard_arrow_down
+1
vote
asked
Apr 23, 2016
by
ram
java
chat_bubble
How do you automate Javascript and CSS file minification for your spring-boot applications?
1
keyboard_arrow_down
+1
vote
asked
Jul 1, 2016
by
anjana
(
46
points)
java
chat_bubble
how do I redirect to page keeping model value?
1
keyboard_arrow_down
0
votes
asked
May 10, 2016
by
anonymous
java
chat_bubble
how do I build JAR file with dependencies?
1
keyboard_arrow_down
0
votes
asked
Apr 18, 2016
by
Bhoopathy
maven
java
Remember
Register
add
...