Witam tak jak w temacie nie wiem jak napisać dany tekst aby się zamienił a nie dodawał. Mój kod:
public void changePass() throws IOException {
File file = new File(fileName);
Scanner scann = new Scanner(file);
Scanner scan = new Scanner(System.in);
System.out.println("Podaj stare hasło");
String oldPass = scan.nextLine();
if (oldPass.equals(pass)) {
System.out.println("Podaj nowe hasło");
String newPass = scan.nextLine();
try (
FileWriter fileWriter = new FileWriter(fileName, true);
BufferedWriter writer = new BufferedWriter(fileWriter)
){
writer.write(" hasło: " + newPass);
System.out.println("Zapisano");
} catch (IOException e) {
e.printStackTrace();
}
}
}
w 2 linijce kodu zamiast zastąpić ją całą to się dodaje tekst np linijka 2 " hasło: xxx" po tym evencie wygląda " hasło: xxx hasło: yyy" a chce aby wyglądało " hasło: yyy"