added reverse byte order function
This commit is contained in:
parent
542b242c41
commit
0495d3289b
2 changed files with 23 additions and 0 deletions
|
|
@ -95,6 +95,21 @@ public class ByteUtil {
|
|||
return dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new byte array with reversed byte ordering
|
||||
* (LittleEndian -> BigEndian, BigEndian -> LittleEndian)
|
||||
*
|
||||
* @param data is the byte array that will be reversed.
|
||||
* @return a new byte array that will have the same data but in reverse byte order
|
||||
*/
|
||||
public static byte[] getReverseByteOrder(byte[] data){
|
||||
byte[] dest = new byte[data.length];
|
||||
if (data.length > 0)
|
||||
for (int i=0; i<data.length; ++i)
|
||||
dest[dest.length-1-i] = data[i];
|
||||
return dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a byte bitmask
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue