• Post Reply Bookmark Topic Watch Topic
  • New Topic

FileChannel rollback question  RSS feed

 
M Burke
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When FileChannel calls the transferFrom() method, if it fails in the middle somewhere, does it rollback it's changes?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
M Burke
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!