I am looking for a match in the file with the entered string. Next I need to change the found string to the one entered for the replacement. The search did:
private void handleButtonAction3(ActionEvent event) throws FileNotFoundException, IOException { String searchWord = scrfield.getText(); String changeWord = chngfield.getText(); byte[] content; try (FileInputStream fis = new FileInputStream(file);) { content = new byte[fis.available()]; fis.read(content); } String[] lines = new String(content).split("\n"); int i = 1; for (String line : lines) { String[] words = line.split(" "); int j = 1; for (String word : words) { if (word.equalsIgnoreCase(searchWord)) { ansarea.appendText("Found: "+word+"\n"); //замена ansarea.appendText("Replaced successfully."); find = true; } j++; } i++; }if(find == false) ansarea.appendText("Совпадений не найдено! \n Nothing to change!"); }