TD2: Check for message text emptyness.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 17 Mar 2018 15:27:55 +0000 (16:27 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 17 Mar 2018 15:27:55 +0000 (16:27 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TD2/IHM/IHM.java
TD2/IHM/ThreadIHMSend.java
TD2/client/ThreadClientSend.java
TD2/client/ThreadClientoSend.java

index 22624fcc9a8749b12819655f7a33dbf260094993..5a43687654e919f5b1a45c29905736824b7d6563 100644 (file)
@@ -94,7 +94,7 @@ public class IHM implements ActionListener {
             e.printStackTrace();
         }
         String mess = (String)sendMessages.remove(0);
-        if (mess.length() == 0)
+        if (mess.isEmpty())
             return "";
         System.out.println("IHM -> message a envoyer : " + mess);
         return randName + "> " + mess;
index f8077c968fdf03ed6dc4098fc04670180418d282..5113989da7208d3ba9e9ee222bb3094239a993cf 100644 (file)
@@ -17,7 +17,7 @@ public class ThreadIHMSend implements Runnable {
                 if (line.equals(".")) {
                     end = true;
                 }
-                if (line.length() != 0) {
+                if (!line.isEmpty()) {
                     client.sendMsg(line);
                     System.out.println(Thread.currentThread().getName() + " a envoye " + line);
                 }
index 639228fe45f6eef313a2abd9998b92ca721c9b9d..2ba2491e48a49f2e46d42ab7a1a6431d6a652be7 100644 (file)
@@ -17,7 +17,7 @@ public class ThreadClientSend implements Runnable {
                 if (line.equals(".")) {
                     end = true;
                 }
-                if (line.length() != 0) {
+                if (!line.isEmpty()) {
                     client.sendMsg(line);
                     System.out.println(Thread.currentThread().getName() + " a envoye " + line);
                 }
index 1d7e232ffd794bde82be90199f8662d283cf02f7..2475be6d7c80245e5b00eb830d0ff4c778c14e85 100644 (file)
@@ -38,7 +38,7 @@ public class ThreadClientoSend implements Runnable {
                 if (line.equals(".")) {
                     end = true;
                 }
-                if (line.length() != 0) {
+                if (!line.isEmpty()) {
                     Message oMsg = new Message(randName, line, Calendar.getInstance());
                     client.sendoMsg(oMsg);
                     System.out.println(Thread.currentThread().getName() + " a envoye " + oMsg);