Get the common files names in 2 different directories – Java Utility

/**
* This will return common file names from the List
* @param localListOfFiles
* @param sdpListOfFiles
* @return
*/
public static List getCommonFileNames(File[] localListOfFiles,File[] sdpListOfFiles)
{
List<String> commonFiles=new ArrayList<String>();
for (int j = 0; j < localListOfFiles.length; j++) {
for (int k = 0; k < sdpListOfFiles.length; k++) {
//System.out.println(“File ” + localListOfFiles[i].getName());
String localName = localListOfFiles[j].getName();
String sdpName= sdpListOfFiles[k].getName();
if(localName.equalsIgnoreCase(sdpName))
{
commonFiles.add(localName);
}
}
}
return commonFiles;
}

Advertisements

About ashokabhat

I am a C,C ,JAVA,Adobe Flex,.NET Programmer Currently working as a Software Developer
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s