Thanks Chandra and Jim for your valuable Suggestions.
I have got the logic right this time.
I asked for help just 6 hours back and there are replies in just minutes !!
This is the best java forum available on the planet.
I apologize to Henry ( MOD of SCJP) forum for a repost.
I used Hashtables.
ht1 , ht2
Snippets from my working code.........to enthusiasts
Hashtable ht1 = convertToHash("C:\\file1.sql");
Hashtable ht2 = convertToHash("C:\\file2.sql");
boolean filesEqual = true;
Iterator it = ht1.keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();
if (!ht2.containsKey(key)) {
filesEqual = false;
break;
}
}
if (filesEqual)
System.out.println("Files are equal");
else
System.out.println("Files are not equal");
and when I call the function convertToHash
the function does the following
static Hashtable convertToHash(String fileName) throws Exception{
Hashtable<String,String> ht = new Hashtable<String,String>();
BufferedReader in = new BufferedReader(new FileReader(fileName));
while( (line = in.readLine()) != null)
file.append(line);
String[] queries = file.toString().split(";");
for(String str:queries) {
ht.put(str, "");
}
return ht;