views:

79

answers:

2

I'm using the java.util.zip library and ZipOutputStream in order to create a zip file of a directory and all the files and directories under it. In my application, it is likely that another thread could be accessing these same files during the compression. I'm not an expert on file compression (or thread-safety, for that matter) so my question is, will zipping a directory while something else is accessing those files affect either process?

+3  A: 

Only if the processes have opened the files in such a way that prevents read access by other processes. (This usually requires OS-specific flags to specify the permissions.) So it's certainly possible, but it's not the common case.

Promit
+1  A: 

Assuming that you're operating on Windows, and that your concurrent access is read-only, then I would expect the zipping process not to affect anything.

For a detailed approach to Java File Locking, see the JDC Tech Tips.

jsight