The goal is to periodically read files from a folder to which another program outputs them, and then feed the files into another part of my code.
How can I accomplish this with the best trade off between performance and readable and easy code?
(I need to accomplish this in both C# and Java. hence the double tagging, (and no, this is not homework :))
I/O is a bottle neck for most programs but if you’re going for performance there are a couple things you can do to help. One, is only read when you need to. This can be accomplished by using FileSystemWatcher to tell you when the file is changed. The second is, if possible, spawn a new thread to do the I/O if you can continue without the operation being completed.