I have a piece of code that monitors a directory for addition of files. Whenever a new file is added to the directory, the contents of the file are picked and published on kafka
You have to close all the connection which is accessing that file before deleting it.