summaryrefslogtreecommitdiff
path: root/src/Client/ChatClientWriter.java
blob: 3405fd17b98c647fa8201dd5b008b1ef239f58b6 (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 phrase;

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

		} catch (IOException e)	{}

	}

}