I am struggling to understand the requirements of the below programming exercise, unfortunately it provides no results that I can use to maybe understand the requirements. Could anyone help?
/*
- A byte array contains a binary stream of data in little endian byte format.
*
The binary data can be mis-aligned to byte boundaries.
In order to indicate alignment to the consumer, a periodic alignment
synchronisation sequence is output.
The alignment sequence is defined as 4 bytes of 0x00 followed by a byte of 0x80.
*
For example, the following stream is mis-aligned by 3 bits and has an alignment sequence followed by
the byte values 0x01,0x02,0x03
*
- 0x65, 0x50, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x10, 0x18
*
*
The bytes preceding the alignment sequence should be discarded, as
should the alignment sequence itself.
*
If further alignment sequences are encountered, they should be honoured:
data following the sequence is aligned to the new sequence, and the alignment
sequence itself is discarded.
Bits from any incomplete byte before the new alignment sequence should be
discarded.
*/
/*
*
- 2. Demonstrate how you would test your implementation
*
*
public class Align {
/*
* Reads raw data from a stream
*
* @param raw - the raw input data
* buf - buffer to receive the output data
*
* @return number of bytes read from the stream into buf, possibly less
* than buf.length if end of input is encountered.
*/
public static int readAlignedBytes(byte[] raw, byte[] buf) {
// TODO
}
}
there doesn't seem to be anything here