Q:

to find new location of files that are moved to different location - Java

I have a folder of header files in older version of our application.
There are many header files directly inside that folder and also inside many subfolders... Now we are going to use a newer version of the application in which the header files path are present in different subfolders than they used to be before. I want to write a java program(preferably), that gives me a one to one mapping of the old path and the new path of the headers. I have the root directory of header files in both the version... i want to find the differences in header file path with respect to the root directories.
Header files Root Directory of Old Version: Root1
Header Files Root Directory of New Version: Root2
Under Root1 consider there are three sub folders: Folder1, Folder2, Folder3
Under Root2 consider there are three sub folders: Folder1, Folder2, Folder3
Under Root1/Folder1 there were three files: File1,File2,File3
Root1/Folder1/File1,
Root1/Folder1/File2,
Root1/Folder1/File3.

Now in new version these files are like:
Root2/Folder1/File1,
Root2/Folder2/File3,
Root2/Folder3/File2.

The files are restructured.
I want to write a program to find out the new version path for these files by scanning both the root folders:
Required output:
Root1/Folder1/File1 = Root2/Folder1/File1
Root1/Folder1/File2 = Root2/Folder3/File2
Root1/Folder1/File3 = Root2/Folder2/File3.

Sorry if I am not clear. SO is a reference site if we are facing any problem in programming. I am stuck with this running out of ideas for this logic. Kindly Help.
EDIT 1:
sorry for the delay.. the file names are same in both the versions. let me tell the requirement. throughout the project, hundreds of header files are included referring to old version... its c and cpp based code. now we need to change in code all the include statements according to new header paths. so manually changing one by one searching through the windows explorer is tedious. it doesn't matter if the header files have changed. new function definitions might have been added in the new version. but we need to include the same header file.
this program might save a lot of manual hours. Thanks :)

A:

This assumes that file names do not change during the migration from one directory tree into the other one.
This is quick and dirty and lacks all sanity checks and error handling, but it illustrates the main point: recursive descent into a directory to collect the files to collect a mapping of file names to paths. The comp method just takes the names from the first directory tree and displays path names from both trees.
public void find( File root, Map<String, String> map ){
    File[] entries = root.listFiles();
    for( File file: entries ){
        if( file.isDirectory() ){
            find( file, map );
        } else {
            map.put( file.getName(), file.getAbsolutePath() );
        }
    }
}

public void comp( File root1, File root2 ){
    Map<String,String> map1 = new HashMap<>();
    find( root1, map1 );
    Map<String,String> map2 = new HashMap<>();
    find( root2, map2 );
    for( String name1: map1.keySet() ){
        String path1 = map1.get( name1 );
        String path2 = map2.get( name1 );
        System.out.println( name1 + ": " + path1 + "->" + path2 ); 
    }
}

