I am getting really tired from this problem, and I do not know what to do.
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;
}
- The problem is in while WITH FOR(x y: z) IF (), other things
work. -
(If i will delete whole FOR, it seems, that it works, but I need counting.)
-
IN THE CLASS OPERATION IS ONLY GETTER AND SETTER for “name” and “ammount”.
- Explanation
- I read a file.
- I read only topic from a file.
- I load that like a Operation(name = title, ammount = how many times is the same in file)
- I give it to ArrayList = IT DOESNT WORK VERY WELL !!!
- From ArrayList to Set, thats to interface.
- Interface to GUI.
EDIT1: “Exception in thread “AWT-EventQueue-0″ java.lang.NullPointerException”
I hope anyone will understand,
Thanks to everybody,
MmM …
In your
forloop, you have this line:This doesn’t have any check on line existence as you have done in while condition ->
reader.existsLine(). This makes it to read the lines and may fail here or last statement in thewhile, if there are no more lines to read.I am not sure, you really want to read the line within the
forloop. if yes, wrap in the if condition as: