Java Byte Flip flipBytes(int data)

Here you can find the source of flipBytes(int data)

Description

flip Bytes

License

Open Source License

Declaration

private static int flipBytes(int data) 

Method Source Code

//package com.java2s;
/******************************************************************************
 * Copyright (c) 2004, 2006 IBM Corporation 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
 *
 * Contributors:/* ww  w . j  ava 2 s . c om*/
 *    IBM Corporation - initial API and implementation 
 ****************************************************************************/

public class Main {
    private static int flipBytes(int data) {
        int byte1 = data & 0xff;
        int byte2 = (data & 0xff00) >>> 8;
        int byte3 = (data & 0xff0000) >>> 16;
        int byte4 = (data & 0xff000000) >>> 24;

        data = byte1 << 24;
        data += byte2 << 16;
        data += byte3 << 8;
        data += byte4;

        return data;
    }
}

Related

  1. flipByte(byte b)
  2. flipBytes(byte[] bytes)