Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.

Commit ff227ea

Browse files
author
andhra21231
committed
Fix Array List And Denoted To 1.1 Version (Major Updates)
1 parent 7cc31be commit ff227ea

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

server/src/main/java/com/server/Server.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.slf4j.LoggerFactory;
1010

1111
import java.io.*;
12+
import java.io.IOException;
1213
import java.net.ServerSocket;
1314
import java.net.Socket;
1415
import java.net.SocketException;
@@ -27,16 +28,13 @@ public class Server {
2728

2829
public static void main(String[] args) throws Exception {
2930
logger.info("Selamat Datang Di PK-Chat. Pastikan Port 9001 Telah Terbuka!");
30-
ServerSocket listener = new ServerSocket(PORT);
3131

32-
try {
32+
try (ServerSocket listener = new ServerSocket(PORT)) {
3333
while (true) {
3434
new Handler(listener.accept()).start();
3535
}
3636
} catch (Exception e) {
3737
e.printStackTrace();
38-
} finally {
39-
listener.close();
4038
}
4139
}
4240

@@ -58,7 +56,6 @@ public Handler(Socket socket) throws IOException {
5856
public void run() {
5957
logger.info("Mencoba menghubungkan pengguna...");
6058
try {
61-
is = socket.getInputStream();
6259
input = new ObjectInputStream(is);
6360
os = socket.getOutputStream();
6461
output = new ObjectOutputStream(os);

0 commit comments

Comments
 (0)