public static byte [] extractHeader(int offset, int headerLen, 
                                      byte [] bytes) {
    // null in = null out ?
    if( bytes == null ) return null;
    // negative in, empty array out
    if( ( offset < 0 ) || ( headerLen < 0 ) ) return EMPTY_BYTE_ARRAY;
    
    // verify that requested length is in the bounds of the array
    int useLen = ( headerLen <= (bytes.length-offset) ? 
		   headerLen : (bytes.length-offset) );
    // verify that requested offset is also in the bounds
    if( useLen <= 0 ) return EMPTY_BYTE_ARRAY;
                   
    byte [] header = new byte[useLen];
    System.arraycopy(bytes, offset, header, 0, useLen);
    return header;
  }