Is it only Sun that guaruntees the data type sizes? I would think that whoever writes the JRE determines their data type sizes.
int mast = 0xff000000;
for (int i = 0; i <= 32 ; i+=8) {
bytearray[i/8] = (myInt & mask) >> (24 - i);
mask >> 8;
}
That loop should work too, just substitute your integer size for 32, byte size for 8, and (int size - byte size) for 24.... i think