i'm trying to replace some letters in txt file and rewrite it but i can't keep indents at all. Source file looks like this :
aaaaaaaaaWRPaaaaaaaa
bbbWRPbbbbbbbbbbbbbb
here's what i've tried :
public static  void fileReader (String path) throws FileNotFoundException, IOException {
    File prevfile = new File(path);
    BufferedReader reader = new BufferedReader(new FileReader(prevfile));
    String line = reader.readLine();
    while (line!=null){
        content = content  + line + "\n" ;
        line = reader.readLine();
    }
    String newCOntent = content.replaceAll("WRP","WRD");
    FileWriter writer = new FileWriter(prevfile);
    writer.write(newContent);
    writer.close();
    reader.close();
}
}
after which i get output in a single line.
