In Java solution of the following problem, getting NZEC on closing bufferedReader.

Hi,

I have been solving the following question.
http://www.codechef.com/problems/WALK
the question is an easy one.
My question is regarding this solution.
http://ideone.com/zbSaAy
if i keep br.close() in the code, codechef judge gives runtime error.
if i remove this, then my code is accepted.
I am facing the same problem in many codes.

Can anyone please help.

Thank you very much

Brother, remove .close(). When a file is “opened,” the OS marks the file as locked, generally so it can’t be deleted by other processes while it’s being used. x.close() undoes the lock, allowing the OS and other processes to do what it wishes with the file. I’ve answered it in recent post : Java - closing BufferedReader - general - CodeChef Discuss & your corrected code: GkbF9p - Online Java Compiler & Debugging Tool - Ideone.com

3 Likes