From 03a13b6164d44f0c74e5cd180abecbb8e0dda30a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 17 Mar 2018 16:27:55 +0100 Subject: [PATCH] TD2: Check for message text emptyness. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- TD2/IHM/IHM.java | 2 +- TD2/IHM/ThreadIHMSend.java | 2 +- TD2/client/ThreadClientSend.java | 2 +- TD2/client/ThreadClientoSend.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TD2/IHM/IHM.java b/TD2/IHM/IHM.java index 22624fc..5a43687 100644 --- a/TD2/IHM/IHM.java +++ b/TD2/IHM/IHM.java @@ -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; diff --git a/TD2/IHM/ThreadIHMSend.java b/TD2/IHM/ThreadIHMSend.java index f8077c9..5113989 100644 --- a/TD2/IHM/ThreadIHMSend.java +++ b/TD2/IHM/ThreadIHMSend.java @@ -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); } diff --git a/TD2/client/ThreadClientSend.java b/TD2/client/ThreadClientSend.java index 639228f..2ba2491 100644 --- a/TD2/client/ThreadClientSend.java +++ b/TD2/client/ThreadClientSend.java @@ -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); } diff --git a/TD2/client/ThreadClientoSend.java b/TD2/client/ThreadClientoSend.java index 1d7e232..2475be6 100644 --- a/TD2/client/ThreadClientoSend.java +++ b/TD2/client/ThreadClientoSend.java @@ -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); -- 2.34.1