Java Byte Convert From bytesFromLong(long l)

Here you can find the source of bytesFromLong(long l)

Description

bytes From Long

License

Open Source License

Declaration

public static byte[] bytesFromLong(long l) 

Method Source Code

//package com.java2s;
/*/*  w  ww  .java  2s  .c o  m*/
This file is part of Socks via HTTP.
    
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
    
Socks via HTTP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with Socks via HTTP; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

public class Main {
    public static byte[] bytesFromLong(long l) {
        byte[] ret = new byte[8];
        for (int i = 0; i < 8; i++) {
            ret[i] = (byte) l;
            l >>>= 8;
        }
        return (ret);
    }
}

Related

  1. booleanAsByte(boolean val)
  2. bytesFrom(String hwAddress)
  3. bytesFromDpid(long dpid)
  4. bytesFromHex(String s)
  5. bytesFromHexString(String values)
  6. bytesFromString(String bytes)
  7. bytesFromString(String string)