Updating certain values in text file So I need to update some certain values within text file based on actual values there. Any advice on making it more effective or just readable is appreciated. 

Example text file: 

Lalala 
There is tons of text in this file log-12345sr
And somewhere within
There are log file names log-23456sr
Some more text here
I want to edit log file names within Java code
to change the log file names log-34567sr some text here as well
But I want to edit based on current value
For example add 100 to the number in the name
So log-45678sr 
becomes log-45778sr
I can safely assume there is no more than one on a single line


My code:

public static void main(String[] args) throws Exception {
    doModification(new File("test.txt"));
}

public static ArrayList&lt;String&gt; findAllOccurrences(File file, String prefix, String suffix) throws IOException {
    ArrayList&lt;String&gt; occurrences = new ArrayList&lt;&gt;();
    BufferedReader br = new BufferedReader(new FileReader(file));
    String line;
    while ((line = br.readLine()) != null) {
        if (line.contains(prefix) &amp;&amp; line.contains(suffix)) {
            occurrences.add(line.split(prefix)[1].split(suffix)[0]);
        }
    }
    return occurrences;
}

public static HashMap&lt;String,String&gt; buildReplacementMap(ArrayList&lt;String&gt; values, Function&lt;String, String&gt; modification) throws Exception {
    HashMap&lt;String,String&gt; replacementMap = new HashMap&lt;&gt;();
    for(String value: values){
        replacementMap.put(value, modification.apply(value));
    }
    return replacementMap;
}

public static void doModification(File file) throws Exception {
    ArrayList&lt;String&gt; occurrences = findAllOccurrences(file, "log-", "sr");
    HashMap&lt;String, String&gt; replacementMap = buildReplacementMap(occurrences, (value) -&gt; String.valueOf(Long.parseLong(value) - 100));
    String content = new String(Files.readAllBytes(file.toPath()));
    for (Map.Entry&lt;String,String&gt; pair : replacementMap.entrySet()){
        content = content.replaceAll(pair.getKey(), pair.getValue());
    }
    Files.write(file.toPath(),content.getBytes());
}


Text file after modification: 

Lalala 
There is tons of text in this file log-12445sr
And somewhere within
There are log file names log-23556sr
Some more text here
I want to edit log file names within Java code
to change the log file names log-34667sr some text here as well
But I want to edit based on current value
For example add 100 to the number in the name
So log-45778sr 
becomes log-45878sr
I can safely assume there is no more than one on a single line
You could simplify with Regular Expressions:

Pattern pattern = Pattern.compile("log-(\\d+)sr");
Matcher matcher = pattern.matcher(input);
StringBuffer buffer = new StringBuffer();
while(matcher.find()) {
  Long value = Long.parseLong(matcher.group(1), 10);
  Long increased = value + 100;
  matcher.appendReplacement(buffer, increased.toString());
}
System.out.println(buffer.toString());