-
Notifications
You must be signed in to change notification settings - Fork 0
/
rs.java
61 lines (44 loc) · 1.21 KB
/
rs.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
54
55
56
57
58
59
60
61
import java.io.*;
import java.net.*;
import java.util.*;
public class rs
{
public static void main(String args[]) throws Exception
{
Scanner in=new Scanner(System.in);
String x="";
int b,c=0;
try
{
ServerSocket skt1=new ServerSocket(1111);
Socket sk1=skt1.accept();
System.out.println("Connected");
DataInputStream odis1=new DataInputStream(sk1.getInputStream());
DataOutputStream odos1=new DataOutputStream(sk1.getOutputStream());
FileReader fr1=new FileReader("root.txt");
BufferedReader br1=new BufferedReader(fr1);
String line1;
int flag1=0,flag2=0;
String user=odis1.readUTF();
System.out.println(user);
String temp="";
while((line1=br1.readLine())!=null)
{
String[] arr=line1.split(",",2);
if(arr[0].equals(user))
{
odos1.writeUTF(arr[1]);
temp=temp+line1;
}
}
Writer writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("local.txt", true), "UTF-8"));
writer.append("\n");
writer.append(temp);
writer.close();
fr1.close();
sk1.close();
}catch(EOFException exp){}
catch(Exception ep){}
}
}