Hi Everyone,

I have a unique problem....

We have a C++ code that does the following:

Java Code:
//Creat Object of Class, ObjClass
for(int i=0;i<255;i++){
  [B]  objClass.set(int a, int b)[/B]
}

In Java we have the following code:
We are supposed to write the value of a and b that we set in the c++ code inside the java code.

Java Code:
class ObjClss {

{
        Writer writer = null;

        File file = new File("fileWrite.txt");
        writer = new BufferedWriter(new FileWriter(file));
}
        public void set(int a, int b){

try{
           //Some Business Logic
           //Write the value of a and b in file.
           writer.write(a);
           writer.write(b);
           }catch(IOException e){
//do Some Handling
}finally{[B]writer.close();[/B]}


}
But when i execute this, I find that only the last values of a and b are getting written into the file.
When I analysed I found that, thats due to closing of the writer object.(in bold)

But I am stuck as to where should I close the writer oject.:confused:

Please help...
Thanks in advance.....