InputStream in = ClientSocket.getInputStream();
new Thread()
{
public void run() {
while (true)
{
int i = in.read();
handleInput(i);
}
}
}.start();
Ich höre mit diesem Code auf neue Daten auf einem Socket und erhalte:
FaceNetChat.java:37: unreported exception java.io.IOException; must be caught or declared to be thrown
int i = in.read();
^
Wenn ich " throws IOException " nach dem " run() " Ich verstehe:
FaceNetChat.java:34: run() in cannot implement run() in java.lang.Runnable; overridden method does not throw java.io.IOException
public void run() throws IOException {
^
Wahrscheinlich ist es etwas Einfaches, aber ich bin ratlos. Wie kann ich das umgehen?