How to find and replace a given string with new string in a file

This is the second solution to find and replace a given string with a new string in a file. This approach uses the FileReader, Scanner, FileWriter, BufferedWriter, and String methods.

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class ReplaceUsingReplaceAll {

	public static void main(String[] args) throws IOException {

		/* Display the current sampleFile.txt file contents */
		displayFileContent("C:\\Users\\Nagendra\\sampleFile.txt","old");

		/* Re-open the same sampleFile.txt file using FileReader, Scanner
        to search for a given word in each line of this file */

		FileReader fileRead=new FileReader("C:\\Users\\Nagendra\\sampleFile.txt");
		@SuppressWarnings("resource")
		Scanner scanFile=new Scanner(fileRead);
		System.out.println();
		Scanner inpStr=new Scanner(System.in);
		System.out.print("Enter the String to be searched in the given file: ");
		String strToSrch=inpStr.next();

		System.out.print("Enter the String to be replaced in the given file: ");
		String strToReplace=inpStr.next();
		System.out.println("\n");

		/* Open the new sampleFileUpdated.txt file using BufferedWriter and FileWriter */
		FileWriter fWrite=new FileWriter("C:\\Users\\Nagendra\\SampleFileUpdated.txt");
		BufferedWriter  fileToWrite = new BufferedWriter(fWrite);

		/* Read each line of sampleFile.txt, use the replaceAll method of String class */
		while (scanFile.hasNextLine()) {

			/*Write the new line into the sampleFileUpdated.txt file after
            replacing with a given word in each line of sampleFile.txt file*/
			String eachLine=scanFile.nextLine();
			fileToWrite.write(eachLine.replaceAll(strToSrch,strToReplace)+"\n");
		}
		fileToWrite.close();

		/* Display the newly created sampleFileUpdated.txt file contents */
		displayFileContent("C:\\Users\\Nagendra\\SampleFileUpdated.txt","new");
		inpStr.close();
	}

	private static void displayFileContent(String filePath, String neworold) throws IOException {

		/* Display the sample file contents to the console using the
        BufferedReader and FileReader */       

		FileReader fRead=new FileReader(filePath);
		@SuppressWarnings("resource")
		BufferedReader  fileToRd = new BufferedReader(fRead);
		String lineRead;

		System.out.println("The contents of the "+neworold+" file are below");
		System.out.println("----------------------------------");
		while ((lineRead= fileToRd.readLine()) != null)
			System.out.println(lineRead);
		fileToRd.close();
	}
}
OUTPUT:
The contents of the old file are below
----------------------------------
This is the reason why I  like Java language.
Sky is the limit for Java language features.
Hence Java language is in my learning list.
Many people are liking Java language since two decades.

Enter the String to be searched in the given file: Java
Enter the String to be replaced in the given file: Python


The contents of the new file are below
----------------------------------
This is the reason why I  like Python language.
Sky is the limit for Python language features.
Hence Python language is in my learning list.
Many people are liking Python language since two decades.