FileDocCategorySizeDatePackage
ChannelTokenizer.javaAPI DocExample2407Sat Jan 24 10:44:28 GMT 2004je3.nio

ChannelTokenizer

public class ChannelTokenizer extends ByteBufferTokenizer

Fields Summary
static final int
DEFAULT_BUFFER_SIZE
ReadableByteChannel
channel
ByteBuffer
buffer
boolean
hasMoreBytes
Constructors Summary
public ChannelTokenizer(ReadableByteChannel channel, Charset charset)

         // Whether there are any more

    // Construct a ChannelTokenizer to tokenize the specified channel, 
    // decoding its bytes using the specified charset.
         
	this(channel, charset, DEFAULT_BUFFER_SIZE, DEFAULT_BUFFER_SIZE);
    
public ChannelTokenizer(ReadableByteChannel channel, Charset charset, int charBufferSize, int byteBufferSize)

	super(charset, charBufferSize); // Superclass handles charset and size
	this.channel = channel;         // Remember the channel
	this.hasMoreBytes = true;       // Assume some bytes in the channel
	// Allocate the buffer we'll use to store bytes
	buffer = ByteBuffer.allocateDirect(byteBufferSize);
    
Methods Summary
protected java.nio.ByteBuffergetMoreBytes()

	buffer.clear();  // Clear the buffer; prepare to fill it.
	// Read a chunk of bytes
	int bytesRead = channel.read(buffer);
	// If we are at EOF, remember that for hasMoreBytes()
	if (bytesRead == -1) hasMoreBytes = false;
	// Prepare the buffer to be drained and return it
	buffer.flip();   // Set limit to position, and position to 0
	return buffer;   // And return it.
    
protected booleanhasMoreBytes()

 return hasMoreBytes;