aspose file tools
The moose likes Java in General and the fly likes FileChannel rollback question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "FileChannel rollback question" Watch "FileChannel rollback question" New topic
Author

FileChannel rollback question

M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 375
When FileChannel calls the transferFrom() method, if it fails in the middle somewhere, does it rollback it's changes?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
Unlikely. If you're concerned about this, I'd recommend copying the bytes to a tempfile first. If the transferFrom completes successfully, then close the FileChannel and rename the file to whatever name you originally wanted it to have. If a problem occurs during the transfer, simply delete the tempfile afterwards.


"I'm not back." - Bill Harding, Twister
M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 375
I would do that, but I need to append.

There is a method in FileChannel called force(), it is suppose to make recovery possible. But it throws an exception, "Access is denied".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileChannel rollback question
 
Similar Threads
java.io.File
How to input big big ascii files
Locking a file
BufferedReader and FileChannel
how to delete huge amount of records