I am now working with Spring Batch and got a problem in Flat File writing,closing and compressing. What I mean to do is to write a flat file, compress it and send to the respective somewhere. Before compressing, I have to close the file. Well this is fine, but the problem is that if I close the file there is nothing which have been written earlier. Meanwhile,if the file is not closed, I cannot do the compressing. Thus I would like to know how to close properly a file or something else that will work. Please kindly give some suggestions and do me a favor for that.