I am splitting a string with a comma as a delimeter using String.split()
function in java.
Input
1,1,87 gandhi road,600005
Output:
1
1
87
The code stops at whitespace. How do I get it to work ?
I am splitting a string with a comma as a delimeter using String.split()
function in java.
Input
1,1,87 gandhi road,600005
Output:
1
1
87
The code stops at whitespace. How do I get it to work ?
We'll need to see your code before we can begin troubleshooting. However, the following code should work just fine:
String address = "1,1,87 gandhi road,600005";
String[] stringArray = address.split(",");
for(String str : stringArray)
{
// Do something with str.
}
Check the following code:
public class Main {
public static void main(String[] args) {
String[] str = "1,1,87 gandhi road,600005".split(",");
for (String s : str) {
System.out.println(s);
}
}
}
Output:
1
1
87 gandhi road
600005