package Replace;
public class Main
{
public static void main(String[] args)
{
ReplaceTextFile("file.txt", "Hola", "hola");
}
public static void ReplaceTextFile(String urlFile, String textReplace, String newText)
{
java.io.FileReader myfileRd = new java.io.FileReader(urlFile);
java.io.BufferedReader myfileRdBufferedReader = new java.io.BufferedReader(myfileRd);
java.io.FileWriter myfileWr = new java.io.FileWriter("file.txt.out");
String line = " ";
do
{
line = myfileRdBufferedReader.readLine();
if (line != null)
{
line = line.replace(textReplace, newText);
myfileWr.write(line + System.lineSeparator());
}
} while (line != null);
myfileWr.close();
myfileRd.close();
}
}