This code probably comes from C code (or was written by a C programmer who does not parse Java, as well as erickson). This is due to the fact that in Java casting from a type with more information to a type with less information discards bits of a higher order, and therefore in both cases 0xff is not required.
16 , . , , , .
, , ,
1110001100001111 sample
0000000011111111 0xff
0000000000001111 sample & 0xff => first byte`
,
0000000011100011 sample >> 8
0000000011111111 0xff
0000000011100011 (sample >> 8 ) & 0xff => second byte
, erickson (, ).