java – Files. Blocked / synchronized version of copy
I'm trying to copy files from one directory to another, but I hope the call is blocked so that the program will execute only after the entire file transfer
I am currently using files Copy(), which uses non - blocking IO and returns immediately What other options do I have (preferably built into the Java Standard Library) to solve this problem?
Thank you very much, Gareth
Solution
@L_ 419_ 1 @ is not asynchronous. It will not return until the replication is completed
Usually, if a method is asynchronous, Javadoc will be very clear, and the method will accept some form of callback (lambda, or object implementing the interface of the method it will call, etc.) or return something Can be used to check completion (or error) Files. Copy won't do this. Its Javadoc doesn't say it's asynchronous, so there's no reason to doubt it's asynchronous (I just did a quick test to make sure it didn't return until the copy was completed.)