It is sometimes helpful to duplicate a buffer. A duplicate is not a copy or a clone. Rather, it is a new buffer object that has the same internal data as the original buffer, but an independent mark, limit, and position. Changes to the elements in the original bufferthat is, putting data in the bufferaffect the duplicate, and vice versa. However, getting data from one buffer, or flipping, resetting, rewinding, or clearing it, has no effect on the other. Duplicates are often useful when you want to pass the same fixed content to several different operations that run simultaneously or independently.

This is the duplicate method for ByteBuffer:

public abstract ByteBuffer duplicate( )

As usual, each of the seven buffer classes has its own duplicate method that differs primarily in return type. For example, this is the duplicate method for IntBuffer:

public abstract IntBuffer duplicate( )

When the duplicate is created, its position and mark are set to 0 and its limit is set to the capacity, regardless of the position, mark, and limit in the original buffer.

Basic I/O

Introducing I/O

Output Streams

Input Streams

Data Sources

File Streams

Network Streams

Filter Streams

Filter Streams

Print Streams

Data Streams

Streams in Memory

Compressing Streams

JAR Archives

Cryptographic Streams

Object Serialization

New I/O



Nonblocking I/O

The File System

Working with Files

File Dialogs and Choosers


Character Sets and Unicode

Readers and Writers

Formatted I/O with java.text


The Java Communications API


The J2ME Generic Connection Framework


Character Sets

Java I/O
Java I/O
ISBN: 0596527500
EAN: 2147483647
Year: 2004
Pages: 244

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net