I have a file that looks like this:
Dwarf remains:0
Toolkit:1
Cannonball:2
Nulodion's notes:3
Ammo mould:4
Instruction manual:5
Cannon base:6
Cannon base noted:7
Cannon stand:8
Cannon stand noted:9
Cannon barrels:10
... 
What is the easiest way to open this file, search for name and return the value of the field? I cannot use any external libraries.
What i have tried/is this ok?
    public String item(String name) throws IOException{
    String line;
    FileReader in = new FileReader("C:/test.txt");
    BufferedReader br = new BufferedReader(in);
    while ((line = br.readLine()) != null) {
        if(line.contains(name)){
            String[] parts = line.split(":");
            return parts[1];
        }
    }
    return null;
}
 
    