Reputation: 1571
I have the below contents from a .txt file stored into a string variable actual_text
1 1111 47
2 2222 92
3 3333 81
So now actual_text will have the value
1 1111 47
2 2222 92
3 3333 81
I'm trying to achieve two objectives from the below snippet
while(parse till end of string condition) //parse till the end actual_text
{
if(end of line condition) //checking for the "\n" string in actual_text
{
//random code
}
}
Can anyone tell me how to do the parsing and checking the end of line in the above program.
Upvotes: 0
Views: 2407
Reputation: 86774
for (String line : actual_text.split("\\n"))
{
//process each line
}
Upvotes: 2