资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

拨号代码java 拨号代码691什么意思

有没有大神会写在linux下的用java实现宽带的拨号程序

package cn.adsl;

创新互联公司专业为企事业单位提供成都网站建设公司、成都网站设计,网站优化、微信开发、手机网站建设、空间域名、网页空间、企业邮箱等互联网基础服务。成立与2013年,我们先后签约上千多家中小型企业和科技发展公司的网站建设和网站推广项目。通过多年的创新发展,已发展成为专业能力较强,服务较好的建站公司。

import java.io.BufferedReader;

import java.io.InputStreamReader;

public class ConnectNetWork {

/**

* 执行CMD命令,并返回String字符串

*

* @param strCmd

* @return

* @throws Exception

*/

public static String exeCmd(String strCmd) throws Exception {

Process p = Runtime.getRuntime().exec("cmd /c " + strCmd);

StringBuilder sbCmd = new StringBuilder();

BufferedReader br = new BufferedReader(new InputStreamReader(p

.getInputStream()));

String line = null;

while ((line = br.readLine()) != null) {

sbCmd.append(line + "\n");

}

return sbCmd.toString();

}

/**

* 切断ADSL

*

* @param adslTitle

* @return

* @throws Exception

*/

public static boolean cutAdsl(String adslTitle) throws Exception {

// 加上"" 防止空格

String cutAdsl = "rasdial \"" + adslTitle + "\" /disconnect";

String result = exeCmd(cutAdsl);

if (result.indexOf("没有连接") != -1) {

System.err.println(adslTitle + "连接不存在!");

return false;

} else {

System.out.println("连接已断开");

return true;

}

}

/**

* 连接ADSL

*

* @param adslTitle

* @param adslName

* @param adslPass

* @param adslPhone

* @return

* @throws Exception

*/

public static boolean connAdsl(String adslTitle, String adslName,

String adslPass, String adslPhone) throws Exception {

// 加上"" 防止空格

String adslCmd = "rasdial \"" + adslTitle + "\" " + adslName + " "

+ adslPass + " /phone:" + adslPhone;

String tempCmd = exeCmd(adslCmd);

if (tempCmd.indexOf("已连接") 0) {

System.out.println("已成功建立连接.");

return true;

} else {

System.err.println(tempCmd);

System.err.println("建立连接失败");

return false;

}

}

/**

* @param args

*/

public static void main(String[] args) throws Exception {

// rasdial "宽带名" /disconnect

String adsl = "宽带名";

String username = "username";

String password = "password";

String phone = "#12345678";

cutAdsl(adsl);

Thread.sleep(4000);

// rasdial "宽带名" 用户名 密码 /phone:#123456789

connAdsl(adsl, username, password, phone);

}

}

大神用java写宽带拨号 怎么写啊 能不能教下我

package cn.adsl;

import java.io.BufferedReader;

import java.io.InputStreamReader;

public class ConnectNetWork {

/**

* 执行CMD命令,并返回String字符串

*

* @param strCmd

* @return

* @throws Exception

*/

public static String exeCmd(String strCmd) throws Exception {

Process p = Runtime.getRuntime().exec("cmd /c " + strCmd);

StringBuilder sbCmd = new StringBuilder();

BufferedReader br = new BufferedReader(new InputStreamReader(p

.getInputStream()));

String line = null;

while ((line = br.readLine()) != null) {

sbCmd.append(line + "\n");

}

return sbCmd.toString();

}

/**

* 切断ADSL

*

* @param adslTitle

* @return

* @throws Exception

*/

public static boolean cutAdsl(String adslTitle) throws Exception {

// 加上"" 防止空格

String cutAdsl = "rasdial \"" + adslTitle + "\" /disconnect";

String result = exeCmd(cutAdsl);

if (result.indexOf("没有连接") != -1) {

System.err.println(adslTitle + "连接不存在!");

return false;

} else {

System.out.println("连接已断开");

return true;

}

}

/**

* 连接ADSL

*

* @param adslTitle

* @param adslName

* @param adslPass

* @param adslPhone

* @return

* @throws Exception

*/

public static boolean connAdsl(String adslTitle, String adslName,

String adslPass, String adslPhone) throws Exception {

// 加上"" 防止空格

String adslCmd = "rasdial \"" + adslTitle + "\" " + adslName + " "

+ adslPass + " /phone:" + adslPhone;

String tempCmd = exeCmd(adslCmd);

if (tempCmd.indexOf("已连接") 0) {

System.out.println("已成功建立连接.");

return true;

} else {

System.err.println(tempCmd);

System.err.println("建立连接失败");

return false;

}

}

/**

* @param args

*/

public static void main(String[] args) throws Exception {

// rasdial "宽带名" /disconnect

String adsl = "宽带名";

String username = "username";

String password = "password";

String phone = "#12345678";

cutAdsl(adsl);

Thread.sleep(4000);

// rasdial "宽带名" 用户名 密码 /phone:#123456789

connAdsl(adsl, username, password, phone);

}

}

我想要一个宽带拨号的Java代码实现 可以在Eclipse里面运行的 就是那种普通的PPPOE连接上网 输入账号密码

这个要底层操作的吧,Java 做比较难吧, 但是 Runtime 调用本地的连接程序还可以试下 。


分享文章:拨号代码java 拨号代码691什么意思
网址分享:http://cdkjz.cn/article/ddodddp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220