我将.txt文件中的以下内容存储到字符串变量 actual_text
1 1111 47
2 2222 92
3 3333 81
现在 actual_text 将具有值
1 1111 47
2 2222 92
3 3333 81
我正在尝试从以下代码段中实现两个目标
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
}
}
任何人都可以告诉我如何在上面的程序中解析和检查行尾。
答案 0 :(得分:2)
for (String line : actual_text.split("\\n"))
{
//process each line
}