Can a file be moved?

The Question:

Is there any way of checking whether or not a file can be moved?

The Context

My program is periodically checking a folder for new files. Files are moved into this folder via FTP. My program is designed to then move these files into a different folder. However, I want to ensure that the file has completely arrived.

The Example

For example, a 450MB file will appear to the Java File API, but I won't be able to move it if the file is still copying over.

The Restrictions

I know you can check the success/failure of a move - I don't want to do this (Althought it looks like I'll have no choice).

The results of File.canRead() and File.canWrite() don't help.

I don't want to do nasty tricks like monitoring the file's size over the course of a minute to see if it has stopped increasing.

Message was edited by:

david_bates

Message was edited by:

david_bates

[991 byte] By [david_batesa] at [2007-10-2 21:18:17]
# 1
The most reliable way of seeing whether a file can be moved is to try to move it.The most reliable way of seeing whether operation X will succeed is to attempt operation X. For any X.
ejpa at 2007-7-14 0:27:09 > top of Java-index,Core,Core APIs...
# 2
Crossposted and answered (again): http://forum.java.sun.com/thread.jspa?threadID=740698&tstart=0
ejpa at 2007-7-14 0:27:09 > top of Java-index,Core,Core APIs...