2012-10-26 45 views
0

我变得非常厌倦了这个问题,我不知道该怎么办找到。编辑在收集

import ... 
class ... 

private ArrayList <Operation> operationList = new ArrayList<Operation>(); 

@Override 
public Collection<String> lineList() { 
    Set <String> groupOperation = new HashSet<String>(); 
    Operace newOperation= null; 

    LogFileReader reader = new LogFileReader(nameFile); 
    LogEntry line = reader.nextLine(); 

    while(reader.existsLine()) { 
     for(Operation whatever2: operationList) { 
      if(line.getOperation().equals(whatever2.getName())) { 
       whatever2.setAmmount(whatever2.getAmmount()+1); 
       line = reader.nextLine(); 
      } 
     } 
     newOperation = new Operation(line.getOperation()); 
     newOperation.setAmmount(1); 
     groupOperation .add(newOperation); 
     line = reader.nextLine(); 
    } 
    .... 
    return groupOperation; 
} 
  • 的问题是在同时随着对(x和y:Z)IF(),其他的事情 工作。
  • (如果我会删除整个FOR,现在看来,它的工作原理,但我需要计时。)

  • 在类的操作只getter和setter的“名”和“ammount的”。

    1. 解释
    2. 我读的文件。
    3. 我从文件中读取唯一的话题。
    4. 我加载类似于一个操作(名称=标题,ammount =文件中有多少次相同)
    5. 我给它的ArrayList = IT DOESNT工作非常好!
    6. 从ArrayList的设置,这就是接口。
    7. GUI接口。

EDIT1: “异常线程 ”AWT-EventQueue的-0“ 显示java.lang.NullPointerException”

我希望有人会明白,

感谢大家,

MmM ...

+0

您需要发布SSCCE(http://sscce.org/)。这将有助于您获得更好的答案,并让人们了解您的要求。 – Coupon22

+0

请发布完整的stacktrace。 – Coupon22

回答

1

在您的for循环中,您有以下行:

 line = reader.nextLine(); 

这不会对线存在任何检查,你在while条件都做 - >reader.existsLine()。如果没有更多的行要读取,这将使其读取行并在while中的最后语句中失败。

我不知道,你真的想读for环内的线。如果是,则在if条件中包装为:

 if(reader.existsLine()){ 
      line = reader.nextLine(); 
     } 
+0

感谢您的回复。你说得对。我失明了,我看了一个小时,什么都没有。非常感谢。 –