I'm trying to make a game between 2 computers but 1st I need I need to know how to check data exchanged between computers. Here is the part I dont undrestand

Java Code:
try{
         InetAddress group = InetAddress.getByName("225.0.0.1");
         MulticastSocket ms=new MulticastSocket(this.port);
         ms.joinGroup(group);
         String recieved = null;
         String text ="number isnt 2";
          String text1 ="number is 2";
            while(true){
                 byte[] buf=new byte[256];
                 DatagramPacket packet = new DatagramPacket(buf, buf.length);
                 ms.receive(packet);
                 
                    recieved =new String(packet.getData());
                  

                      if(  recieved.matches("2")){
                       tf.setText(this.tf.getText()+text1+"\n");
                  }else{
                      tf.setText(this.tf.getText()+text+"\n");
                  }
             tf.setText(this.tf.getText()+recieved+"\n");
                 
            }


        } catch (Exception exception) {
            exception.printStackTrace();
        }
if I send "2", it says it isnt 2 but it prints 2, I got it working using recieved.contains though but I'm looking for other options. Any ideas? thanks in advance for feedback.