summaryrefslogtreecommitdiff
path: root/src/Client/ChatClientWriter.java
blob: ba35bf246d362ccf195e9dcf0ee16631c310f99c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package Client;
import java.io.*;
import java.net.Socket;
import java.util.*;

public class ChatClientWriter extends Thread
{
	private Socket soc;

	public static Scanner reader = new Scanner(System.in);

	public ChatClientWriter(Socket soc)
	{
		this.soc = soc;
	}

	public void run()
	{
		try
		{
			OutputStreamWriter outTemp;
			String line;

			outTemp = new OutputStreamWriter(this.soc.getOutputStream());
			BufferedWriter output = new BufferedWriter(outTemp);
		
			while (true)
			{
				System.out.print("Write here: > ");
				line = reader.nextLine();
				output.write(line, 0, line.length());
				output.newLine();
				output.flush();
			}

		} catch (IOException e)	{}

	}

}