-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileClient.java
More file actions
28 lines (23 loc) · 912 Bytes
/
FileClient.java
File metadata and controls
28 lines (23 loc) · 912 Bytes
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
import java.io.*;
import java.net.*;
public class FileClient {
public static void main(String[] args) throws Exception {
Socket socket = new Socket("localhost", 5000);
System.out.println("Connected to server!");
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter filename: ");
String filename = console.readLine();
out.println(filename);
System.out.println("\nFile Content:");
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
out.close();
console.close();
socket.close();
}
}