repositories
/
TD_SR.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TD2: Check for message text emptyness.
[TD_SR.git]
/
TD2
/
client
/
ThreadClientSend.java
diff --git
a/TD2/client/ThreadClientSend.java
b/TD2/client/ThreadClientSend.java
index 59ffbd0bab538c80a6b6f82f3ab094089fa7f7d1..2ba2491e48a49f2e46d42ab7a1a6431d6a652be7 100644
(file)
--- a/
TD2/client/ThreadClientSend.java
+++ b/
TD2/client/ThreadClientSend.java
@@
-1,4
+1,3
@@
-import java.util.concurrent.ThreadLocalRandom;
import java.io.*;
public class ThreadClientSend implements Runnable {
import java.io.*;
public class ThreadClientSend implements Runnable {
@@
-13,28
+12,31
@@
public class ThreadClientSend implements Runnable {
try {
userInput = new BufferedReader(new InputStreamReader(System.in));
boolean end = false;
try {
userInput = new BufferedReader(new InputStreamReader(System.in));
boolean end = false;
-
while (!end) {
-
String line = userInput.readLine();
-
if (line.equals(".")) {
+ while (!end) {
+ String line = userInput.readLine();
+ if (line.equals(".")) {
end = true;
}
end = true;
}
- client.sendMsg(line);
- System.out.println(Thread.currentThread().getName() + " a envoye " + line);
+ if (!line.isEmpty()) {
+ client.sendMsg(line);
+ System.out.println(Thread.currentThread().getName() + " a envoye " + line);
+ }
}
}
-
}
+ }
catch (IOException e) {
System.err.println("IOException: " + e);
e.printStackTrace();
}
finally {
if (userInput != null) {
catch (IOException e) {
System.err.println("IOException: " + e);
e.printStackTrace();
}
finally {
if (userInput != null) {
- try {
- userInput.close();
- }
- catch (IOException e) {
- System.err.println("IOException: " + e);
- }
- }
+ try {
+ userInput.close();
+ }
+ catch (IOException e) {
+ System.err.println("IOException: " + e);
+ e.printStackTrace();
+ }
+ }
}
}
}
}
}
}