我有一个程序有时会遇到errorjava.net.SocketException。有没有一种方法可以让客户端程序在(且仅当)遇到此错误以“处理”错误时执行一些代码?完整的错误是
java.net.SocketException: Software caused connection abort: socket write error
这是我现在所拥有的摘要。
public void run() {
try {
//some code that causes the SocketException
}
catch (SocketException e) {
System.out.println("I recognize the SocketException");
}
}
但是,尽管出现错误,它仍然不会打印该行。
这是完整的错误
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown Source)
at java.io.ObjectOutputStream.writeNonProxyDesc(Unknown Source)
at java.io.ObjectOutputStream.writeClassDesc(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeFatalException(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at (...).java:61)
at (...).java:164)