-
Notifications
You must be signed in to change notification settings - Fork 0
/
ls.java
65 lines (48 loc) · 1.16 KB
/
ls.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
62
63
64
65
import java.io.*;
import java.net.*;
import java.util.*;
public class ls
{
public static void main(String args[]) throws Exception
{
Scanner in=new Scanner(System.in);
String x="";
int b,c=0;
try
{
ServerSocket skt=new ServerSocket(2598);
Socket sk=skt.accept();
System.out.println("Connected");
DataInputStream odis=new DataInputStream(sk.getInputStream());
DataOutputStream odos=new DataOutputStream(sk.getOutputStream());
String ipv="";
FileReader fr=new FileReader("local.txt");
BufferedReader br1=new BufferedReader(fr);
StringBuffer sb=new StringBuffer();
String line1;
int flag1=0,flag2=0,flag=0;
String user=odis.readUTF();
System.out.println(user);
while((line1=br1.readLine())!=null)
{
String[] arr=line1.split(",",2);
if(arr[0].equals(user))
{
flag=1;
ipv = arr[1];
}
}
if(flag==0)
{
odos.writeUTF("Not found in local server..");
}
else
{
odos.writeUTF(ipv);
}
fr.close();
sk.close();
}catch(EOFException exp){}
catch(Exception ep){}
}
}