Here you can find the source of intToLittleEndian(int val)
Parameter | Description |
---|---|
val | a parameter |
public final static byte[] intToLittleEndian(int val)
//package com.java2s; /*/*w w w . j a va 2s.c o m*/ * Copyright (c) 2014 Stephan D. Cote' - All rights reserved. * * This program and the accompanying materials are made available under the * terms of the MIT License which accompanies this distribution, and is * available at http://creativecommons.org/licenses/MIT/ * * Contributors: * Stephan D. Cote * - Initial API and implementation */ public class Main { /** * Converts a long to a little-endian four-byte array * * @param val * * @return array of byte representing little-endian encoding of the value */ public final static byte[] intToLittleEndian(int val) { final byte[] b = new byte[4]; for (int i = 0; i < 4; i++) { b[i] = (byte) (val % 256); val = val / 256; } return b; } }