forked from cyhe66/CodeB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExchangeClient.java
More file actions
45 lines (40 loc) · 1.28 KB
/
Copy pathExchangeClient.java
File metadata and controls
45 lines (40 loc) · 1.28 KB
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
/**
*
* @author atamarkin2
*/
public class ExchangeClient {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
if (args.length < 5) {
System.out.println("Usage: \nclientTask <host> <port> <user> <password> <command...>");
}
Socket socket = new Socket(args[0], Integer.parseInt(args[1]));
PrintWriter pout = new PrintWriter(socket.getOutputStream());
BufferedReader bin = new BufferedReader(new InputStreamReader(socket.getInputStream()));
pout.println(args[2] + " " + args[3]);
for (int i = 4; i < args.length; i++) {
pout.println(args[i]);
}
pout.println("CLOSE_CONNECTION");
pout.flush();
String line;
while ((line = bin.readLine()) != null) {
System.out.println(line);
}
pout.close();
bin.close();
}
}