<div ng-repeat="item in items | filter: predicate(criteria)"
...
$scope.predicate = function(criteria) {
return function (item) {
return criteria.field === item.field; // тут можно сравнивать как угодно.
}
}
...
public class Reader {
private List users = new ArrayList();
public void read(String path) {
BufferedReader readFromFile = null;
try {
readFromFile = new BufferedReader(new FileReader(path));
String line = null;
while ((line = readFromFile.readLine()) != null) {
User newUser = new User(line);
users.add(newUser);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (readFromFile != null)
try {
readFromFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public int calculateSum() {
int sum = 0;
for (User user : users) {
sum += user.getKey();
}
return sum;
}
private class User {
public int key = 0;
public String value;
public User(String line) {
if (line != null && !line.isEmpty()) {
String[] entries = line.split("\\s", 2);
this.key = Integer.valueOf(entries[0]); // можно завернуть в
// try {} catch
this.value = entries[1];
} else {
// логируем
}
}
public int getKey() {
return key;
}
public String getValue() {
return value;
}
}
public static void main(String[] args) {
Reader reader = new Reader();
reader.read("src//1.txt");
System.out.println(reader.calculateSum());
}
}