I think I also need a BufferedWriter and FileWriter but I do not want to write inside the file I just want to read it, modify what is already read and rest it inside a String
public String substituye(String parrafo)
{
StringBuilder content = new StringBuilder();
File file = Paths.get("desktop/pagina.html").toFile();
String linea="";
try(BufferedReader br = new BufferedReader(new FileReader(file)))
{
while(br.ready())
{
linea = br.readLine();
if(linea.equals("//inicio del parrafo de modificar"))
linea = parrafo;
content.append(linea+"\n");
}
}
catch(IOException io)
{
io.printStackTrace();
}
return content.toString();
}
// the problem is that it modifies the file only at the beginning and does not eliminate the rest. That is, it is as if I had deleted the old title of the paragraph and instead of the paragraph in the variable "Paragraph" but the body of the rest of the old paragraph is still there