Skip to Content
Java in a Nutshell, 5th Edition
book

Java in a Nutshell, 5th Edition

by David Flanagan
March 2005
Intermediate to advanced
1254 pages
104h 21m
English
O'Reilly Media, Inc.
Content preview from Java in a Nutshell, 5th Edition

Name

ScatteringByteChannel

Synopsis

This interface extends ReadableByteChannel and adds two additional read( ) methods that read bytes for a channel and “scatter” them to an array (or subarray) of buffers. These methods are passed an array of ByteBuffer objects, and, optionally, an offset and length that define the region of the array to be used. The read( ) method attempts to read enough bytes from the channel to fill each of the specified buffers in the order in which they appear in the buffer array (the “scattering” process is actually much more orderly and linear than the name implies). The return value of the method is the number of bytes actually read, which may be different than the sum of the remaining bytes in the buffers. See ReadableByteChannel for a discussion of exceptions and thread-safety that apply to these read( ) methods as well.

java.nio.channels.ScatteringByteChannel

Figure 13-36. java.nio.channels.ScatteringByteChannel

public interface ScatteringByteChannel extends ReadableByteChannel {
// Public Instance Methods
     long read(java.nio.ByteBuffer[ ] dsts) throws java.io.IOException;  
     long read(java.nio.ByteBuffer[ ] dsts, int offset, int length) 
throws java.io.IOException;  
}

Implementations

DatagramChannel, FileChannel, Pipe.SourceChannel, SocketChannel

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 4th Edition

Learning Java, 4th Edition

Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 0596007736Supplemental ContentErrata Page