-
Notifications
You must be signed in to change notification settings - Fork 0
/
excelclient.java
78 lines (63 loc) · 2.08 KB
/
excelclient.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
66
67
68
69
70
71
72
73
74
75
76
77
78
import java.io.*; import java.net.*; import java.util.*;
class excelclient{
public static void main(String[] args)
{
try
{
Socket s=new Socket("localhost",6675);
System.out.println("WELCOME TO THE UOH SU ELECTIONS "
+"\n Fill the following details \n"
+"\nNote: kindly provide the valid information\n");
String id,name,email,branch,gender,dob;
s.setSoTimeout(2000);
Scanner sc=new Scanner(System.in);
System.out.print("Enter the Student iD :: ");
id=sc.nextLine();
System.out.print("Enter the Name of the student ::");
name=sc.nextLine();
System.out.print("Enter the Email address :: ");
email=sc.nextLine();
System.out.println("Enter the Department ::");
branch=sc.nextLine();
System.out.println("Enter the Gender Male (M) / Female (F) ::");
gender=sc.nextLine();
System.out.println("Enter the date of birth in dd-mm-yy");
dob=sc.nextLine();
s.setSoTimeout(1000);
DataOutputStream dou=new DataOutputStream(s.getOutputStream());
dou.writeUTF("Data"+","+name+","+id+","+email+","+branch+","+gender+","+dob);
System.out.println("waitng for response ...");
//InputStreamReader di=new InputStreamReader(s.getInputStream());
//di.readUTF();
//System.out.println(di);
//BufferedReader br=new BufferedReader(di);
//System.out.println(br);
//String res=br.readLine();
DataInputStream di=new DataInputStream(s.getInputStream());
s.setSoTimeout(1000);
String rs=di.readUTF();
System.out.println(rs);
StringTokenizer res=new StringTokenizer(rs,",");
System.out.println("aefae");
String result=res.nextToken();
String login=res.nextToken();
String paswd=res.nextToken();
System.out.println("Received "+ result);
if(result.equals("ok"))
{
System.out.println("Registered Succesfully");
System.out.println("Login Credentials :: ");
System.out.println(login);
System.out.println(paswd);
System.out.println("Note : Dont share the credentials with anyone "+"\nProtecting your RIGHT TO VOTE"+"\n is YOUR RESPONSIBILTY");
}
if(result.equals("notok"))
System.out.println("Invaalid Details");
s.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}