Java Convert via ByteBuffer toArray(int value)

Here you can find the source of toArray(int value)

Description

to Array

License

Open Source License

Declaration

public static byte[] toArray(int value) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    public static byte[] toArray(int value) {
        ByteBuffer buffer = ByteBuffer.allocate(4);
        buffer.order(ByteOrder.BIG_ENDIAN);
        buffer.putInt(value);/* w w w  .ja va  2  s  .c o  m*/
        buffer.flip();
        return buffer.array();
    }
}

Related

  1. stringToIpAddress(String s)
  2. stringToLong(String offsetString)
  3. stringToLongUnknownLength(String str, int startIndex)
  4. to32BitsLongArray(byte[] data, boolean bigEndian)
  5. toArray(final byte[] byteArray, final int sizeLimit)
  6. toArray(IntBuffer src, int[] dst, int offset)
  7. toArray(long length)
  8. toASCII(String str)
  9. toAsciiBytes(String s)