I have this code but when i press the button its edit only the first line in txt file:
String editN = jTextField13.getText();
if(jTextField18.getText().equals("1")){
try{
String verify, putData;
File file = new File("Name.txt");
FileWriter fw = new FileWriter(file);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(editN);
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
while( (verify=br.readLine()) != null )
{
if(verify != null)
{
putData = verify.replaceAll("here", "there");
bw.write(putData);
}
}
br.close();
bw.close();
FileReader fr2 = new FileReader(file);
BufferedReader br2 = new BufferedReader(fr2);
String line1=br2.readLine();
br2.close();
Worker1.setText("1. "+line1);
EditWorker.setVisible(false);
Workers.setVisible(true);
Workers.pack();
}catch(IOException e){
e.printStackTrace();
}
}
What I need to add that it will edit second line? I need to edit something that it will edit the second line in the txt file.
Aucun commentaire:
Enregistrer un commentaire