TD2: Be more informative at exception catching.
[TD_SR.git] / TD2 / client / ThreadClientSend.java
1 import java.io.*;
2
3 public class ThreadClientSend implements Runnable {
4 private SocketClient client;
5
6 ThreadClientSend(SocketClient c) {
7 client = c;
8 }
9
10 public void run() {
11 BufferedReader userInput = null;
12 try {
13 userInput = new BufferedReader(new InputStreamReader(System.in));
14 boolean end = false;
15 while (!end) {
16 String line = userInput.readLine();
17 if (line.equals(".")) {
18 end = true;
19 }
20 client.sendMsg(line);
21 System.out.println(Thread.currentThread().getName() + " a envoye " + line);
22 }
23 }
24 catch (IOException e) {
25 System.err.println("IOException: " + e);
26 e.printStackTrace();
27 }
28 finally {
29 if (userInput != null) {
30 try {
31 userInput.close();
32 }
33 catch (IOException e) {
34 System.err.println("IOException: " + e);
35 e.printStackTrace();
36 }
37 }
38 }
39 }
40 }