code: private void formRequest(){
        byte[] user_bytes = userName.getBytes();
        byte[] password_bytes = password.getBytes();
  
        request = new byte[3+user_bytes.length+password_bytes.length];
        request[0] = (byte) 1; 
        request[1] = (byte) user_bytes.length;
        System.arraycopy(user_bytes,0,request,2,user_bytes.length);
        request[2+user_bytes.length] = (byte) password_bytes.length;
        System.arraycopy(password_bytes,0,
                         request,3+user_bytes.length,password_bytes.length);
     }
docs: Convert UserName password in to binary form, ready to be send to server