Org. neodatis. ODB. Core. Io. bytearrayconverter
The function of this class is: converts array of bytes into Native objects and native objects into array of bytes
Public class bytearrayconverter {
......
/**
* Bit binary bits (or bits) byte 1 byte = 8bit kilobyte (Kb) kilobytes of megabyte (MB) megabytes
* 1 MB = 1024kb = 1024*1024 byte gigabyte (GB) terabyte (TB) Too byte petabyte (PB)
* Exabyte (EB) zetabyte (zb) yottabyte (Yb) nonabyte (NB) doggabyte (db)
*
* Byte type 1 byte-128-127 short integer 2 bytes-2 15 power-2 15 power-1 int integer 4 bytes
* 31 Power-2 31 Power-1 long integer 8 bytes-63 power of 2 ~ 63 power-1 of 2
*
* @ Param s
* @ Return: First low, then high
*/
Public static byte [] Using tobytearray (short S ){
Byte B [] = new byte [2];
Int I, shift;
For (I = 0, shift = 8; I <2; I ++, shift-= 8 ){
B [I] = (byte) (0xff & (S> shift); // & 0000 0000 1111 first low, then high
}
Return B;
}
Public static short bytearraytoshort (byte [] bytes ){
Short result = 0;
For (INT I = 0; I <2; I ++ ){
Result <= 8; // left shift out the last byte
Result | = bytes [I] & 0xff; // or in the new byte
}
Bytes = NULL;
Return result;
}
......