Here you can find the source of long2buff(long n)
Parameter | Description |
---|---|
n | long number |
public static byte[] long2buff(long n)
//package com.java2s; /**/*w w w.j ava 2 s . c o m*/ * Copyright (C) 2008 Happy Fish / YuQing * * FastDFS Java Client may be copied only under the terms of the GNU Lesser * General Public License (LGPL). * Please visit the FastDFS Home Page http://www.csource.org/ for more detail. **/ public class Main { /** * long convert to buff (big-endian) * * @param n * long number * @return 8 bytes buff */ public static byte[] long2buff(long n) { byte[] bs; bs = new byte[8]; bs[0] = (byte) ((n >> 56) & 0xFF); bs[1] = (byte) ((n >> 48) & 0xFF); bs[2] = (byte) ((n >> 40) & 0xFF); bs[3] = (byte) ((n >> 32) & 0xFF); bs[4] = (byte) ((n >> 24) & 0xFF); bs[5] = (byte) ((n >> 16) & 0xFF); bs[6] = (byte) ((n >> 8) & 0xFF); bs[7] = (byte) (n & 0xFF); return bs; } }