All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ml.karmaconfigs.remote.messaging.util.message.DataFixer Maven / Gradle / Ivy

package ml.karmaconfigs.remote.messaging.util.message;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

public final class DataFixer {

    public static byte[] fixByteData(final byte[] data) {
        List byteList = new ArrayList<>();

        for (byte b : data) {
            if (b > 0) {
                byteList.add(b);
            }
        }

        byte[] array = new byte[byteList.size()];
        for (int i = 0; i < array.length; i++) {
            array[i] = byteList.get(i);
        }

        return array;
    }

    public static ByteBuffer fixBuffer(final ByteBuffer original) {
        byte[] tmp = original.array();
        return ByteBuffer.wrap(DataFixer.fixByteData(tmp));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy