1. 程式人生 > >使用try-with-resources

使用try-with-resources

原始碼:

編譯後:

import java.io.IOException;
import java.net.ServerSocket;

public class RpcServer
{
  public void publisher(Object paramObject, int paramInt)
  {
    ServerSocket localServerSocket;
    try
    {
      localServerSocket = new ServerSocket(paramInt); Object localObject = null;

      if (localServerSocket != null) if (localObject != null) try { localServerSocket.close(); } catch (Throwable localThrowable) { localObject.addSuppressed(localThrowable); } else localServerSocket.close(); 
    } catch (IOException localIOException) {
      localIOException.printStackTrace();
    }
  }
}

參考資料: