I solved the problem n Thanks for your reply.
I was having a problem with writing the updated line n rest of the lines, for which I saved as different filename n append the lines.
But my actual requiredment is that to save in the same filename, If you can pls alter my code n advise me.
Here is my code store as a different filename..
Thanks
Cheers
Jowsaki
public void updateCOD(String codfile)
{
System.out.println("Inside UpdateCOD ");
try
{
FileReader codFile = new FileReader(codfile);
BufferedReader br1 = new BufferedReader(codFile);
// Read the first line from the file.
String line1 = br1.readLine();
// As long as the line isn�t null, keep going.
while ( line1 != null )
{
// extract integers from a text file, then do the caculation.
System.out.println("Line1 is "+line1);
if(line1.trim().equals("COD-Type:image/gif"))
{
line1="COD-Type:image/jpeg";
}
try {
BufferedWriter out = new BufferedWriter(new FileWriter(codfile+".bak",true));
out.write(line1);
out.write("\n");
out.close();
} catch (IOException e) {
}
line1 = br1.readLine();
}
br1.close();
codFile.close();
}
catch(FileNotFoundException fne)
{
fne.printStackTrace();
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
}