我目前正在学习Java,并且遇到了这个问题,我想加载一个包含大量行的文件(我正在逐行读取文件),而我想要做的事情是跳过某些行(伪-码)。如何从java中的文本文件跳过某些行?
the line thats starts with (specific word such as "ABC")
我曾尝试使用
if(line.startwith("abc"))
但没有奏效。我不知道如果我做错了,这就是为什么我在这里寻求帮助,下面的负载功能的一部分:
public String loadfile(.........){
//here goes the variables
try {
File data= new File(dataFile);
if (data.exists()) {
br = new BufferedReader(new FileReader(dataFile));
while ((thisLine = br.readLine()) != null) {
if (thisLine.length() > 0) {
tmpLine = thisLine.toString();
tmpLine2 = tmpLine.split(......);
[...]
+1。不知道为什么这被拒绝,但回到0. – Neil 2012-04-04 09:04:44
-1与java-ee servlets或jsp无关以及已被删除的帖子的副本 – 2012-04-04 09:04:48
+1不确定是否投弃权票。如果有错误的标签,只需纠正它们... – devsnd 2012-04-04 09:05:31