I\'m using JSch to get files from an SFTP server, but I\'m trying to figure out a way to only get the oldest file, and to make sure that it is not currently being written to
I don't have a direct answer to your question, but it sounds like you want to do something similar to reliable file transfer. This is part of a larger project in Grid computing that is now apparently organized here. I don't know if it includes security features or if you can add them on, but it is an open source project.