这个条件意味着什么(null ==(is = con.getErrorStream()))

时间:2017-03-10 22:49:56

标签: java if-statement conditional-statements

我在互联网上搜索如何查找http请求:

InputStream is;
if (null == (is = con.getErrorStream())) {
        is = con.getInputStream();
    }

这种情况到底是什么意思?检查此条件时,is变量会采用con.getErrorStream()返回的值吗?

2 个答案:

答案 0 :(得分:3)

是的,is将获取con.getErrorStream()返回的值,然后将is与null进行比较。

答案 1 :(得分:0)

    private static Thread serviceThread;

    private IKeyboardMouseEvents mouseEvents;

    private int currentPixel = 0;
    private List<byte> rgb = new List<byte> { 255, 0, 0 };

    public static void StartService()
    {
        serviceThread?.Abort();
        serviceThread = new Thread(() =>
        {
            Application.Run(new TiltWheelService());
        });

        serviceThread.Start();
    }

    public TiltWheelService()
    {
        mouseEvents = Hook.GlobalEvents();
        mouseEvents.MouseDown += OnMouseDown;
        mouseEvents.MouseWheel += OnMouseScrollWheel;
    }