Java Code Examples for net.fs.utils.Tools#getConnection()

The following examples show how to use net.fs.utils.Tools#getConnection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientUI.java    From finalspeed-91yun with GNU General Public License v2.0 5 votes vote down vote up
public void checkUpdate() {
    for (int i = 0; i < 3; i++) {
        checkingUpdate = true;
        try {
            Properties propServer = new Properties();
            HttpURLConnection uc = Tools.getConnection(updateUrl);
            uc.setUseCaches(false);
            InputStream in = uc.getInputStream();
            propServer.load(in);
            serverVersion = Integer.parseInt(propServer.getProperty("version"));
            break;
        } catch (Exception e) {
            e.printStackTrace();
            try {
                Thread.sleep(3 * 1000);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        } finally {
            checkingUpdate = false;
        }
    }
    if (this.haveNewVersion()) {
        int option = JOptionPane.showConfirmDialog(mainFrame, "发现新版本,立即更新吗?", "提醒", JOptionPane.WARNING_MESSAGE);
        if (option == JOptionPane.YES_OPTION) {
            openUrl(homeUrl);
        }
    }

}
 
Example 2
Source File: ClientUI.java    From finalspeed with GNU General Public License v2.0 5 votes vote down vote up
public void checkUpdate() {
    for (int i = 0; i < 3; i++) {
        checkingUpdate = true;
        try {
            Properties propServer = new Properties();
            HttpURLConnection uc = Tools.getConnection(updateUrl);
            uc.setUseCaches(false);
            InputStream in = uc.getInputStream();
            propServer.load(in);
            serverVersion = Integer.parseInt(propServer.getProperty("version"));
            break;
        } catch (Exception e) {
            e.printStackTrace();
            try {
                Thread.sleep(3 * 1000);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        } finally {
            checkingUpdate = false;
        }
    }
    if (this.haveNewVersion()) {
        int option = JOptionPane.showConfirmDialog(mainFrame, "发现新版本,立即更新吗?", "提醒", JOptionPane
                .YES_NO_CANCEL_OPTION);
        if (option == JOptionPane.YES_OPTION) {
            openUrl(homeUrl);
        }
    }

}