Ike To - 2016-06-02

There is a similar problem in antlr.CharScanner.setInput(). Unluckily, that one really require keeping a state about whether the file is opened by setInput(), and there is an additional problem that it is hard to find the correct place to close the file.

Neglecting to close a file for reading is not as bad as neglecting to close a file for writing. For me, the problem of read comes when I read a file in NFS and then try removing the directory. Because the file is still opened, NFS turns the file to a dummy filename, but the file remains in the directory so the directory removal fail. For write it additionally means the file content might not have been flushed out.

The workaround is, of course, to open the file in the caller and pass the opened file to parse_xls() and save().