Java Array Swap swapByteOrder32(byte[] data, int ofs, int len)

Here you can find the source of swapByteOrder32(byte[] data, int ofs, int len)

Description

swap Byte Order

License

Apache License

Declaration

public static byte[] swapByteOrder32(byte[] data, int ofs, int len) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] swapByteOrder32(byte[] data, int ofs, int len) {
        int end = ofs + len;
        byte tmp;

        for (; ofs < end; ofs += 4) {
            tmp = data[ofs];/*w ww  . j a v a2s. c  o  m*/
            data[ofs] = data[ofs + 3];
            data[ofs + 3] = tmp;

            tmp = data[ofs + 1];
            data[ofs + 1] = data[ofs + 2];
            data[ofs + 2] = tmp;
        }
        return data;
    }
}

Related

  1. swapArrayStr(String[] arr)
  2. swapArrayValues(int i1, int i2, int[] indices)
  3. swapBlocks(byte[] array, int fromA, int toA, int fromB, int toB)
  4. swapByteArray(byte[] source)
  5. swapByteOrder(byte[] a)
  6. swapBytes(byte[] bytes)
  7. swapBytes(byte[] data)
  8. swapBytes(byte[] dataToSwap, int wordByteLength)
  9. swapBytesAt(byte[] bytes, int p1, int p2)