Here you can find the source of longToFourBytes(long value)
Parameter | Description |
---|---|
value | long value |
Parameter | Description |
---|---|
Exception | Exception |
public static final byte[] longToFourBytes(long value) throws Exception
//package com.java2s; /*// ww w.j a va2s .c o m * Copyright (c) 2016 Tata Consultancy Services and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ public class Main { /** * This function converts longToFourBytes * * @param value * long value * @return value byte value * @throws Exception * Exception */ public static final byte[] longToFourBytes(long value) throws Exception { byte[] result = new byte[4]; result[0] = (byte) ((value >>> 24) & 0xFF); result[1] = (byte) ((value >>> 16) & 0xFF); result[2] = (byte) ((value >>> 8) & 0xFF); result[3] = (byte) (value & 0xFF); return result; } }