Java Utililty Methods Convert via ByteBuffer

List of utility methods to do Convert via ByteBuffer

Description

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

Method

ByteBuffertoDirectBuffer(String s)
to Direct Buffer
return toDirectBuffer(s, StandardCharsets.ISO_8859_1);
double[]toDoubleArray(byte[] data)
to Double Array
ByteBuffer buffer = ByteBuffer.wrap(data);
buffer.order(ByteOrder.LITTLE_ENDIAN);
DoubleBuffer doubleBuffer = buffer.asDoubleBuffer();
double[] result = new double[data.length / 8];
for (int i = 0; i < data.length / 8; i++) {
    result[i] = doubleBuffer.get();
return result;
...
FiletoFile(URL url)
Convert from a URL to a File.
if (url == null || !"file".equalsIgnoreCase(url.getProtocol())) {
    return null;
} else {
    String filename = url.getFile().replace('/', File.separatorChar);
    filename = decodeUrl(filename);
    return new File(filename);
FiletoFile(URL url)
Convert from a URL to a File.
if (url == null || !"file".equalsIgnoreCase(url.getProtocol())) {
    return null;
} else {
    String filename = url.getFile().replace('/', File.separatorChar);
    filename = decodeUrl(filename);
    return new File(filename);
File[]toFiles(URL[] urls)
Converts each of an array of URL to a File.
if (urls == null || urls.length == 0) {
    return EMPTY_FILE_ARRAY;
File[] files = new File[urls.length];
for (int i = 0; i < urls.length; i++) {
    URL url = urls[i];
    if (url != null) {
        if (url.getProtocol().equals("file") == false) {
...
floattoFloat(byte[] bytes)
Converts a byte array to a float value
if (bytes == null || bytes.length == 0) {
    return -1L;
return ByteBuffer.wrap(bytes).getFloat();
floattoFloat(final byte[] b)
toFloat.
return ByteBuffer.wrap(b).getFloat();
float[]toFloatArray(int[] intArray)
to Float Array
float[] floats = new float[intArray.length];
for (int i = 0; i < intArray.length; i++) {
    float value = Float.intBitsToFloat(intArray[i]);
    floats[i] = value;
return floats;
byte[]toFloatBytes(List datas)
to Float Bytes
ByteBuffer buf = allocate(48);
for (Double data : datas) {
    buf.putFloat(data.floatValue());
buf.flip();
return buf.array();
byte[]toGuidBytes(UUID theUuid)
to Guid Bytes
ByteBuffer first8 = ByteBuffer.allocate(8);
first8.putLong(theUuid.getMostSignificantBits());
first8.rewind();
byte[] first4 = new byte[4];
first8.get(first4);
reverse(first4);
byte[] second2 = new byte[2];
first8.get(second2);
...