-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFTPClient.java
More file actions
29 lines (25 loc) · 767 Bytes
/
Copy pathFTPClient.java
File metadata and controls
29 lines (25 loc) · 767 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
29
package java_base;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
public class FTPClient {
public static void main(String[] args) throws UnknownHostException, IOException {
// TODO Auto-generated method stub
Socket socket = new Socket("127.0.0.1", 8888);
OutputStream os = socket.getOutputStream();
FileInputStream fis = new FileInputStream("D:\\2.txt");
byte[] ba = new byte[1024];
int len = 0;
while((len = fis.read(ba)) != -1) {
os.write(ba);
}
socket.shutdownInput();
// Scanner sc = new Scanner(socket.getInputStream());
// String msg = sc.nextLine();
// System.out.println(msg);
socket.close();
}
}