[英]Parsing till end of string and checking for end of line in java
我将.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
}
}
任何人都可以告诉我如何解析和检查上述程序中的行结束。
for (String line : actual_text.split("\\n"))
{
//process each line
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.