Skip to content

Commit e84bbed

Browse files
mint-runsmint-runs
authored andcommitted
update OutputStreamThread.java
1 parent 424f835 commit e84bbed

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

src/main/java/de/javasocketapi/core/OutputStreamThread.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,24 @@
55
import java.net.Socket;
66
import java.net.SocketException;
77
import java.util.LinkedList;
8-
import java.util.List;
98
import java.util.Timer;
109
import java.util.TimerTask;
1110

1211
class OutputStreamThread {
1312

1413
private final Client client;
1514
private final Socket socket;
16-
private final List<Packet> packets;
17-
private final Timer timer;
18-
19-
{
20-
this.packets = new LinkedList<>();
21-
this.timer = new Timer();
22-
}
15+
private final LinkedList<Packet> packets = new LinkedList<>();
16+
private final Timer timer = new Timer();
2317

2418
public OutputStreamThread(final Client client) {
2519
this.client = client;
2620
this.socket = this.client.getSocket();
2721
}
2822

29-
public void run() {
23+
public void run() throws IOException {
3024
//initialise outputStream
31-
OutputStream outputStream = null;
32-
try {
33-
outputStream = this.socket.getOutputStream();
34-
} catch (final IOException e) {
35-
e.printStackTrace();
36-
}
37-
final OutputStream finalOutputStream = outputStream;
25+
final OutputStream finalOutputStream = this.socket.getOutputStream();
3826
//start sending send byte arrays
3927
this.timer.scheduleAtFixedRate(new TimerTask() {
4028
@Override
@@ -79,15 +67,13 @@ public void run() {
7967
finalOutputStream.write(bytes);
8068
//flush outputStream
8169
finalOutputStream.flush();
82-
} catch (final SocketException ignored) {
83-
70+
} catch (final SocketException exception) {
71+
exception.printStackTrace();
8472
}
8573
}
8674
}
87-
} catch (final IOException e) {
88-
e.printStackTrace();
89-
} catch (final NullPointerException ignored) {
90-
75+
} catch (final IOException | NullPointerException exception) {
76+
exception.printStackTrace();
9177
}
9278
}
9379
}, 0, 1);

0 commit comments

Comments
 (0)