InputStream in = ClientSocket.getInputStream();
new Thread()
{
public void run() {
while (true)
{
int i = in.read();
handleInput(i);
}
}
}.start();
我正在使用此代码在套接字上收听新数据并获得:
FaceNetChat.java:37: unreported exception java.io.IOException; must be caught or declared to be thrown
int i = in.read();
^
当我在“ run() ”之后添加“ throws IOException ”时,我得到:
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 {
^
这可能很简单,但我不知所措。我如何通过这个?