Hi friend,
import java.io.*;
import java.util.*;
import java.util.regex.Pattern;
public class ReplaceTool{
public static void main(String args[]) throws IOException {
BufferedReader bf = new BufferedReader(new FileReader("Context.txt"));
BufferedReader bf1 = new BufferedReader(new FileReader("amar.txt"));
System.out.println("welcome to india");
String []oldOne = null;
String []newOne = null;
int i = 0;
int count = 0;
String delimiter = "[,]";
int[]limit = {0};
String line;
String line1;
String[] tokens = null;
while((line = bf.readLine())!= null){
for(int j=0; j<count; j++){
int limits= 0;
tokens = line.split(delimiter,limits);
oldOne[i] = tokens[0];
System.out.println("tokens[0] = "+tokens[0]);
System.out.println("tokens[1] = "+tokens[1]);
System.out.println(count);
}
}
while((line1 = bf1.readLine())!= null){
for(i=0;i<count;i++){
String res = line1.replaceAll(oldOne[i], newOne[i]);
System.out.println(res);
}
}
}
}
-------------------------
Read for more information,
http://www.roseindia.net/java/Thanks