我目前正在學習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