ByteBuffer big Endian Wrap - Java java.nio

Java examples for java.nio:ByteBuffer Endian

Description

ByteBuffer big Endian Wrap

Demo Code


//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte[] array = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(bigEndianWrap(array));
    }/*from w w  w.j  a v a2 s.co m*/

    /**
     * @param array the ByteBuffer's content
     * @return a wrapped bigEndian ByteBuffer
     * @see ByteBuffer#wrap(byte[])
     */
    public static ByteBuffer bigEndianWrap(byte[] array) {
        ByteBuffer buf = ByteBuffer.wrap(array);
        buf.order(ByteOrder.BIG_ENDIAN);
        return buf;
    }
}

Related Tutorials