public final class Buffer
extends java.lang.Object
ByteBuffer
. It maintains the same semantics
and mechanisms of the ByteBuffer
.
Java 9 introduced API changes to some methods in ByteBuffer
. Instead
of returning instances of Buffer
, those methods were
rewritten to return instances of ByteBuffer
instead. While this is
perfectly fine at compile time, running "modern" code on Java 8 and earlier
throws NoSuchMethodError
. In order to prevent occurrences of this
exceptions in the future, Buffer
is used consistently in place of
ByteBuffer
. Since it is not possible to directly convert a Buffer
into a ByteBuffer
and the other way around, Buffer
makes it less likely to develop dangerous code in the future.
Modifier and Type | Method and Description |
---|---|
static Buffer |
allocate(int cap) |
static Buffer |
allocateDirect(int cap) |
byte[] |
array() |
Buffer |
asReadOnlyBuffer() |
int |
capacity() |
java.nio.CharBuffer |
decode(java.nio.charset.Charset charset) |
Buffer |
duplicate() |
boolean |
equals(java.lang.Object obj) |
Buffer |
flip() |
byte |
get() |
Buffer |
get(byte[] b) |
Buffer |
get(byte[] b,
int pos,
int len) |
byte |
get(int pos) |
int |
getInt() |
int |
getInt(int pos) |
long |
getLong() |
long |
getLong(int pos) |
short |
getShort(int pos) |
int |
hashCode() |
boolean |
hasRemaining() |
boolean |
isDirect() |
int |
limit() |
Buffer |
limit(int lim) |
static Buffer |
map(java.nio.channels.FileChannel channel,
java.nio.channels.FileChannel.MapMode mode,
long position,
long size) |
Buffer |
mark() |
int |
position() |
Buffer |
position(int pos) |
Buffer |
put(Buffer b) |
Buffer |
put(byte b) |
Buffer |
put(byte[] b) |
Buffer |
put(byte[] buf,
int pos,
int len) |
Buffer |
putInt(int i) |
Buffer |
putLong(long l) |
int |
readFully(java.nio.channels.FileChannel channel,
int position) |
int |
remaining() |
Buffer |
reset() |
Buffer |
rewind() |
Buffer |
slice() |
void |
update(java.util.zip.CRC32 checksum) |
static Buffer |
wrap(byte[] buffer) |
static Buffer |
wrap(byte[] buffer,
int pos,
int len) |
int |
write(java.nio.channels.WritableByteChannel channel) |
public static Buffer map(java.nio.channels.FileChannel channel, java.nio.channels.FileChannel.MapMode mode, long position, long size) throws java.io.IOException
java.io.IOException
public static Buffer wrap(byte[] buffer)
public static Buffer wrap(byte[] buffer, int pos, int len)
public static Buffer allocate(int cap)
public static Buffer allocateDirect(int cap)
public int remaining()
public Buffer asReadOnlyBuffer()
public Buffer position(int pos)
public int position()
public Buffer limit(int lim)
public int limit()
public Buffer slice()
public int readFully(java.nio.channels.FileChannel channel, int position) throws java.io.IOException
java.io.IOException
public Buffer flip()
public int getInt()
public int getInt(int pos)
public Buffer mark()
public Buffer get(byte[] b)
public Buffer get(byte[] b, int pos, int len)
public byte get(int pos)
public byte get()
public Buffer reset()
public void update(java.util.zip.CRC32 checksum)
public byte[] array()
public int capacity()
public boolean isDirect()
public Buffer put(byte[] b)
public Buffer put(byte[] buf, int pos, int len)
public Buffer put(byte b)
public Buffer rewind()
public long getLong(int pos)
public long getLong()
public short getShort(int pos)
public Buffer duplicate()
public java.nio.CharBuffer decode(java.nio.charset.Charset charset)
public boolean hasRemaining()
public int write(java.nio.channels.WritableByteChannel channel) throws java.io.IOException
java.io.IOException
public Buffer putInt(int i)
public Buffer putLong(long l)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Copyright © 2010 - 2020 Adobe. All Rights Reserved