try (BufferedReader br = new BufferedReader(new FileReader("test.txt"))) {
String line;
while ((line = br.readLine()) != null) {
if (line.startsWith("count:")) {
String[] parts = line.split(" ");
if (parts.length > 1) {
int count = Integer.valueOf(parts[1]);
System.out.println("count: " + ++count);
}
}
else {
System.out.println(line);
}
}
}
catch (IOException exc) {
exc.printStackTrace();
}