Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

About to process big file, use the nio  RSS feed

 
Scott Ding
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to copy big file quickly , following code is in my application. Please give me some advice. thanks.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that should work pretty well. It's inefficient for small files (mapping is expesive) but for big files it should be pretty good. However my guess is that if you're just copying bytes, with no modifications at all, you may get better performance from the following:

I don't really know what will be fastest; I just assume using mapping won't be faster, simply because if it were, they would just reimplement transferTo() using mapping, and then there would be no difference. But if transferTo() were faster, it wouldn't be so easy to implement map() using transferTo(). So it seems unlikely map() will be faster. If you've got a huge file though, try both and see. Also try

Should be the same as transferFrom(), but you never know...
 
Scott Ding
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good
very thanks
I'll try it.
I guess transferTo is better.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!