Java Utililty Methods ByteBuffer to Float

List of utility methods to do ByteBuffer to Float

  1. HOME
  2. Java
  3. B
  4. ByteBuffer to Float

Description

The list of methods to do ByteBuffer to Float are organized into topic(s).

Method

float readFloat(ByteBuffer buffer)
read Float
return Float.intBitsToFloat(readInt(buffer));
float[] readFloatArray(ByteBuffer bb, int length)
read Float Array
float[] a = new float[length];
for (int i = 0; i < length; i++) {
 a[i] = bb.getFloat();
return a;
float[] readFloats(final ByteBuffer bb, final int length)
read Floats
final float[] result = new float[length];
for (int index = 0; index < length; index++) {
 result[index] = bb.getFloat();
return result;
int toFloat(AudioFormat format, ByteBuffer buf, float[] floatBuf)
to Float
if (format.isBigEndian()) {
 if (format.getSampleSizeInBits() == 16) {
 return toFloat16BE(buf, floatBuf);
 } else {
 return toFloat24BE(buf, floatBuf);
} else {
 if (format.getSampleSizeInBits() == 16) {
...
float toFloat(ByteBuffer buffer)
to Float
return toByteBuffer(buffer, Float.BYTES).getFloat();
float toFloat(ByteBuffer bytes)
to Float
return bytes.getFloat(bytes.position());
float toFloat(ByteBuffer value)
to Float
float result = 0f;
try {
 if (value != null) {
 int originPos = value.position();
 result = value.getFloat();
 value.position(originPos);
} catch (Exception ex) {
...
void toFloat16BE(ByteBuffer buf, FloatBuffer out)
to Float BE
while (buf.remaining() >= 2 && out.hasRemaining()) {
 out.put(r16 * (short) (((buf.get() & 0xff) << 8) | (buf.get() & 0xff)));
int toFloat24BE(ByteBuffer buf, float[] out)
to Float BE
int samples = 0;
while (buf.remaining() >= 3 && samples < out.length) {
 out[samples++] = r24
 * ((((buf.get() & 0xff) << 24) | ((buf.get() & 0xff) << 16) | ((buf.get() & 0xff) << 8)) >> 8);
return samples;


AltStyle によって変換されたページ (->オリジナル) /