Here you can find the source of toString(FloatBuffer buffer)
Parameter | Description |
---|---|
buffer | - the float buffer to toString to System.out |
public static String toString(FloatBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.charset.StandardCharsets; public class Main { /**//from ww w .j av a 2 s. com * Utility method to toString a float buffer * * @param buffer - the float buffer to toString to System.out */ public static String toString(FloatBuffer buffer) { StringBuilder str = new StringBuilder(buffer.capacity() * 2); str.append('['); for (int i = 0; i < buffer.capacity(); i++) { str.append(buffer.get(i)); if (i != buffer.capacity() - 1) { str.append(", "); } } str.append(']'); return str.toString(); } public static String toString(ByteBuffer buffer) { byte[] inBytes = new byte[buffer.capacity()]; buffer.get(inBytes); byte[] outBytes = inBytes; for (int i = 0; i < inBytes.length; i++) { byte b = inBytes[i]; if (b == 0x00) { outBytes = new byte[i]; System.arraycopy(inBytes, 0, outBytes, 0, i); break; } } return new String(outBytes, StandardCharsets.UTF_8); } }