日期:2014-05-20  浏览次数:20708 次

求用java自动重启自家路由器代码,用批处理也可以。
可以用http://192.168.1.1 进入,需要输入密码。 可以修改进入的端口号。

求各位大侠给个代码。。。。谢谢!!!

------解决方案--------------------
呃,没做过。帮顶了,祝楼主好运啊
------解决方案--------------------
Java code

package net;

import java.net.Authenticator;
import java.net.PasswordAuthentication;

public class DialogAuthenticator extends Authenticator {
    private static final DialogAuthenticator instance = new DialogAuthenticator();

    private DialogAuthenticator() {
        super();
    }

    public static DialogAuthenticator getInstance() {
        return instance;
    }

    @Override
    protected PasswordAuthentication getPasswordAuthentication() {
        String site = this.getRequestingSite().getHostAddress();
        if (site.trim().indexOf("127.0.0.1") != -1) {
            return new PasswordAuthentication("admin", "admin".toCharArray());
        } else {
            return null;
        }
    }
}