public final class ByteTools extends Object implements Serializable
| Constructor and Description |
|---|
ByteTools() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
append(byte[] src,
byte[] dest)
Appends one byte array to another.
|
static byte[] |
append(byte[] src,
byte[] dest,
int pos)
append one byte array to an empty array
of the proper size
usage:
newarray = bytetool.append(sourcearray, destinationarray, position to start copy at);
|
static byte[] |
cLongToLEBytes(int i) |
byte[] |
cLongToLEBytesOLD(int i)
C Longs are only 32 bits, Java Longs are 64.
|
static short[] |
cLongToLEShorts(int x)
C Longs are only 32 bits, Java Longs are 64.
|
static byte[] |
doubleToByteArray(double d) |
static byte[] |
doubleToLEByteArray(double d) |
static double |
eightBytetoLEDouble(byte[] bite)
converts and bitswaps an eight bite byte array into an IEEE double.
|
static long |
eightBytetoLELong(byte[] bite)
converts and bitswaps an eight bite byte array into an IEEE double.
|
static String |
getByteDump(byte[] bt,
int offset)
Returns a string representation of the byte array.
|
static String |
getByteDump(byte[] bt,
int offset,
int len)
Returns a string representation of the byte array.
|
static byte[] |
getBytes(List<?> records)
Get an array of bytes from a collection of byte arrays
Seems slow, why 2 iterations, should be faster way?
|
static String |
getByteString(byte[] bt,
boolean pad)
Returns a string representation of the byte array.
|
static byte[] |
getExcelEncoding(String s) |
static boolean |
isUnicode(String s) |
static byte[] |
longToByteArray(long l) |
static byte[] |
longToLEByteArray(long l)
This is a working longToLEByteArray.
|
static int |
readInt(byte[] bs)
same as readInt, but takes 4 raw bytes instead of 2 shorts
|
static int |
readInt(byte[] b,
int offset)
Reads a 4 byte int from a byte array at the specified position
and handles a little endian conversion
|
static int |
readInt(byte b1,
byte b2,
byte b3,
byte b4)
same as readInt, but takes 4 raw bytes instead of 2 shorts
|
static int |
readInt(int low,
int high)
bit-flipping action converting a 'little-endian'
pair of shorts to a 'big-endian' long.
|
static short |
readShort(int low,
int high)
bit-flipping action converting a 'little-endian'
pair of bytes to a 'big-endian' short.
|
static int |
readUnsignedShort(byte low,
byte high)
bit-flipping action converting a 'little-endian'
pair of bytes to a 'big-endian' short.
|
static byte[] |
shortToLEBytes(short x)
take 16-bit short apart into two 8-bit bytes.
|
static byte[] |
toBEByteArray(double d) |
static short |
updateGrBit(short grbit,
boolean set,
int bitNum)
generic method to update (set or clear) a short at bitNum
|
static void |
writeToFile(byte[] b,
String fname)
write bytes to a file
|
public static String getByteDump(byte[] bt, int offset)
bt - the byte arrayoffset - - offset into byte arraypublic static String getByteDump(byte[] bt, int offset, int len)
bt - the byte arrayoffset - - offset into byte arraylen - - length of byte array segment to returnpublic static String getByteString(byte[] bt, boolean pad)
bt - the byte arraypad - whether to pad the strings so they alignpublic static byte[] append(byte[] src,
byte[] dest)
src - the array which will be appended to destdest - the array to which src will be appendedNullPointerException - if both inputs are nullpublic static byte[] append(byte[] src,
byte[] dest,
int pos)
public static byte[] cLongToLEBytes(int i)
public static short[] cLongToLEShorts(int x)
public static byte[] doubleToLEByteArray(double d)
public static byte[] doubleToByteArray(double d)
public static double eightBytetoLEDouble(byte[] bite)
public static long eightBytetoLELong(byte[] bite)
public static byte[] getBytes(List<?> records)
public static byte[] getExcelEncoding(String s)
public static byte[] longToLEByteArray(long l)
l - public static boolean isUnicode(String s)
public static byte[] longToByteArray(long l)
public static int readInt(byte[] bs)
public static int readInt(byte b1,
byte b2,
byte b3,
byte b4)
public static int readInt(byte[] b,
int offset)
public static int readInt(int low,
int high)
public static int readUnsignedShort(byte low,
byte high)
public static short readShort(int low,
int high)
public static byte[] shortToLEBytes(short x)
public static byte[] toBEByteArray(double d)
public static void writeToFile(byte[] b,
String fname)
public byte[] cLongToLEBytesOLD(int i)
public static short updateGrBit(short grbit,
boolean set,
int bitNum)
set - bitNum - Copyright © 2002–2019 Starter Inc.. All rights reserved.