RC_ 2016-08-05 03:18 采纳率: 60%
浏览 1015
已结题

我想获得我家路由器管理登录后的html文档,很简单的几行代码。大神帮忙看一下

import java.io.*;
import java.net.*;
class Test1 extends Authenticator
{

char password[]={1,2,3,4,5,6,7,8};

public PasswordAuthentication getPasswordAuthentication()
{
    return new PasswordAuthentication("admin",password);
}

}
public class Test
{
public static void main(String args[]) throws IOException
{
Authenticator.setDefault(new Test1());
URL url=new URL("http://192.168.1.1/");
InputStream in=new BufferedInputStream(url.openStream());
Reader r=new InputStreamReader(in);
int c;
while((c=r.read())!=-1)
{
System.out.print((char)c);
}
}
}
报错是这样的Exception in thread "main" java.net.ProtocolException: Server redirected too many times (20)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at Test.main(Test.java:19)

  • 写回答

2条回答 默认 最新

  • wuwenlian 2016-08-05 03:23
    关注

    没有引入recourse吧

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!