-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathChatter.java
53 lines (42 loc) · 960 Bytes
/
Chatter.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.io.*;
import java.net.*;
abstract class Chatter
{
Socket s;
//either on the client side or
//the server side
boolean d=false;
public boolean isDecrypt() {
return d;
}
public OutputStream getOutputStream() throws Exception{
return s.getOutputStream();
}
public InputStream getInputStream() throws Exception{
return s.getInputStream();
}
public String readLine()
{
String line = "";
try
{
BufferedReader input =
new BufferedReader(
new InputStreamReader(
s.getInputStream()));
line = input.readLine();
}
catch(Exception e)
{
line = e.toString();
}
return line;
}
public void writeLine(String line)
throws Exception
{
PrintWriter output =
new PrintWriter(s.getOutputStream(),true);
output.println(line);
}
}