Does java.nio.FileChannel automatically buffer writes?

R

robertjparks

Hi, I am using java.nio.FileChannel to write out very large files. Each
call to channel.write() only writes a few bytes at a time. Will my
program run faster if I build up a large ByteBuffer before calling
channel.write() or do FileChannels automatically buffer for you?

Thanks for your help!
Rob
 
A

Andrey Kuznetsov

Hi, I am using java.nio.FileChannel to write out very large files. Each
call to channel.write() only writes a few bytes at a time. Will my
program run faster if I build up a large ByteBuffer before calling
channel.write() or do FileChannels automatically buffer for you?

no auto buffering.
You have to use your own buffer.
Say from 50 till 512 KB is ok.
Unified I/O could make buffering for you, however it does not work with
Channels.

Andrey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top