CODE
try
{
DataOutputStream o1=new DataOutputStream(new
FileOutputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
World\\Project\\Material\\art\\System Agents\\Form Agents\\CandidateResponses\\Form
Agents.txt"));
//Reading the contents of the files
BufferedReader br= new BufferedReader(new InputStreamReader(new
FileInputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
World\\Project\\Material\\art\\System Agents\\Form Agents\\Ideological\\Form
Agents.txt")));
BufferedReader br1= new BufferedReader(new InputStreamReader(new
FileInputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
World\\Project\\Material\\art\\System Agents\\Form Agents\\Related\\Form
Agents.txt")));
while((s=br.readLine())!=null)
s1+=s+"\n";
while((s2=br1.readLine())!=null)
s3+=s2+"\n";
int numTokens = 0;
StringTokenizer st = new StringTokenizer(s1);
String[] a = new String[10000];
String[] br_n=new String[10000];
int i=0;
while (st.hasMoreTokens())
{
s2 = st.nextToken();
a[i]=s2.substring(0,s2.length()-3);
s6=s2.substring(s2.length()-2);
br_n[i]=s6;
i++;
numTokens++;
}
int numTokens1 = 0;
StringTokenizer st1 = new StringTokenizer (s3);
String[] b = new String[10000];
String[] br1_n=new String[1000];
int j=0;
while (st1.hasMoreTokens())
{
s4 = st1.nextToken();
b[j]=s4.substring(0,s4.length()-3);
s7=s4.substring(s4.length()-2);
br1_n[j]=s7;
j++;
numTokens1++;
}
int x=0;
for(int m=0;m<a.length;m++)
{
for(int n=0;n<b.length;n++)
{
if(a[m].equalsIgnoreCase(b[n])){
int sc=Integer.parseInt(br_n[m]);
int sc1=Integer.parseInt(br1_n[n]);
int score=sc+sc1;
o.writeBytes(a[m]+","score"\n");
break;
}
else
{
o.writeBytes(a[m]+","br_n[m]"\n");
break;
}
}
}
}
}
}catch(Exception e){}
Please correct the code.
For example here i showed two files named as
Form Agents.txt
action,65
architecture,85
eco-,15
essay,30
form,85
form,85
link,40
tangent,25
************************************************************
Form Agents1.txt
Black holes,69
essay,78
*************************************************************
My requirement is
Combine both files and store the following output in another file,
********************************************************************************
*
Expected Output:
action,65
architecture,85
Black holes,69
eco-,15
essay,108 (here the common field value is added)
form,85
form,85
link,40
tangent,25
********************************************************************************
****