■ ■ ■ ■ ■ ■
Projects/4_Server_for_file_transfers/src/com/exemple/Client.java
Projects/4_Server_for_file_transfers/src/com/client/Client.java
1 | | - | package com.exemple; |
| 1 | + | package com.client; |
2 | 2 | | |
3 | 3 | | import javax.swing.*; |
4 | 4 | | import java.awt.*; |
| skipped 3 lines |
8 | 8 | | import java.io.FileInputStream; |
9 | 9 | | import java.net.Socket; |
10 | 10 | | |
11 | | - | import static javafx.application.Platform.exit; |
12 | | - | |
13 | 11 | | public class Client { |
14 | 12 | | private static DataOutputStream dataOutputStream = null; |
15 | 13 | | private static DataInputStream dataInputStream = null; |
16 | 14 | | private static String HOST= "localhost"; |
| 15 | + | private static Integer PORT= 5000; |
17 | 16 | | |
18 | 17 | | public static void main(String[] args) { |
19 | 18 | | while (true) { |
| skipped 13 lines |
33 | 32 | | int i = file.showSaveDialog(null); |
34 | 33 | | if (1 == i) { |
35 | 34 | | System.out.println("Arquivo não informado"); |
36 | | - | exit(); |
37 | 35 | | break; |
38 | 36 | | } else { |
39 | | - | Socket socket = new Socket(HOST, 5000); |
| 37 | + | Socket socket = new Socket(HOST,PORT); |
40 | 38 | | |
41 | 39 | | dataInputStream = new DataInputStream(socket.getInputStream()); |
42 | 40 | | dataOutputStream = new DataOutputStream(socket.getOutputStream()); |
| skipped 2 lines |
45 | 43 | | sendFile(arquivo.getPath()); |
46 | 44 | | dataInputStream.close(); |
47 | 45 | | dataInputStream.close(); |
| 46 | + | socket.close(); |
48 | 47 | | } |
49 | 48 | | } catch (Exception e) { |
50 | 49 | | e.printStackTrace(); |
| skipped 22 lines |